Skip to content

Commit

Permalink
feat: Add workflow for drafting releases
Browse files Browse the repository at this point in the history
  • Loading branch information
mailo-nr committed Feb 11, 2025
1 parent 71f99a2 commit b92d8ea
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 33 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/release-draft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: 📜 Release | Draft

on:
push:
tags:
- '*.*.*'

env:
REGISTRY: ${{ secrets.OTELCOMM_AWS_TEST_ACC_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
distribution:
- nr-otel-collector
- nrdot-collector-host
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # required for tag metadata

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true

- name: Tidy go.mod files
run: go mod tidy

- name: Verify build
run: make ci DISTRIBUTIONS=${{ matrix.distribution }}

- name: Login to Docker
uses: docker/login-action@v3
if: ${{ env.ACT }}
with:
registry: docker.io
username: ${{ secrets.OTELCOMM_DOCKER_HUB_USERNAME }}
password: ${{ secrets.OTELCOMM_DOCKER_HUB_PASSWORD }}

- uses: docker/setup-qemu-action@v2

- uses: docker/setup-buildx-action@v2

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}

- name: Write GPG to path in memory for signing rpm/deb
id: write_gpg_to_path
run: |
GPG_KEY_PATH="$(mktemp /dev/shm/gpg.XXXXXX)"
echo "$GPG_PRIVATE_KEY" | base64 -d >> "$GPG_KEY_PATH"
echo "gpg_key_path=$GPG_KEY_PATH" >> $GITHUB_OUTPUT
env:
GPG_PRIVATE_KEY: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.OTELCOMM_AWS_TEST_ACC_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.OTELCOMM_AWS_TEST_ACC_SECRET_ACCESS_KEY }}
aws-region: us-east-1
role-to-assume: arn:aws:iam::${{ secrets.OTELCOMM_AWS_TEST_ACC_ACCOUNT_ID }}:role/resource-provisioner
role-skip-session-tagging: true

- name: Login to ECR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY}}/${{ matrix.distribution }}

- name: Build binaries & packages with GoReleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v6
env:
NFPM_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_KEY_PATH: ${{ steps.write_gpg_to_path.outputs.gpg_key_path }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
distribution: goreleaser
version: '~> v2'
args: --clean --skip=announce --timeout 2h
workdir: distributions/${{ matrix.distribution }}

draft-release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23'

- name: Draft Release From Root Config
id: goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: --clean --timeout 2h
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
builds:
- skip: true
release:
draft: true
use_existing_draft: true
mode: replace
11 changes: 2 additions & 9 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ const (
HostDistro = "nrdot-collector-host"
K8sDistro = "nrdot-collector-k8s"

DockerHub = "newrelic"
EnvRegistry = "{{ .Env.REGISTRY }}"

BinaryNamePrefix = "nrdot-collector"
ImageNamePrefix = "nrdot-collector"
)

var (
ImagePrefixes = []string{DockerHub}
NightlyImagePrefixes = []string{EnvRegistry}
ImagePrefixes = []string{EnvRegistry}

Architectures = []string{"amd64", "arm64"}
DefaultConfigDists = map[string]bool{LegacyDistro: true, HostDistro: true}
Expand Down Expand Up @@ -79,7 +77,7 @@ func Generate(dist string, nightly bool) config.Project {
Blobs: Blobs(dist, nightly),
Release: config.Release{
// Disable releases on all distros for now
Disable: "true",
Draft: true,
},
}
}
Expand Down Expand Up @@ -276,7 +274,6 @@ func DockerImage(dist string, nightly bool, arch string, armVersion string) conf
latestPrefixFormat := "%s/%s:latest-%s"

if nightly {
imagePrefixes = NightlyImagePrefixes
prefixFormat = "%s/%s:{{ .Version }}-nightly-%s"
latestPrefixFormat = "%s/%s:nightly-%s"
}
Expand Down Expand Up @@ -324,10 +321,6 @@ func DockerManifests(dist string, nightly bool) []config.DockerManifest {

imagePrefixes := ImagePrefixes

if nightly {
imagePrefixes = NightlyImagePrefixes
}

for _, prefix := range imagePrefixes {
if nightly {
r = append(r, DockerManifest(prefix, "nightly", dist, nightly))
Expand Down
2 changes: 1 addition & 1 deletion distributions/nr-otel-collector/.goreleaser-nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
project_name: nrdot-collector-releases-nightly
release:
disable: "true"
draft: true
builds:
- id: nr-otel-collector
goos:
Expand Down
22 changes: 11 additions & 11 deletions distributions/nr-otel-collector/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
project_name: nrdot-collector-releases
release:
disable: "true"
draft: true
builds:
- id: nr-otel-collector
goos:
Expand Down Expand Up @@ -77,8 +77,8 @@ dockers:
goarch: amd64
dockerfile: Dockerfile
image_templates:
- newrelic/nr-otel-collector:{{ .Version }}-amd64
- newrelic/nr-otel-collector:latest-amd64
- '{{ .Env.REGISTRY }}/nr-otel-collector:{{ .Version }}-amd64'
- '{{ .Env.REGISTRY }}/nr-otel-collector:latest-amd64'
extra_files:
- config.yaml
build_flag_templates:
Expand All @@ -95,8 +95,8 @@ dockers:
goarch: arm64
dockerfile: Dockerfile
image_templates:
- newrelic/nr-otel-collector:{{ .Version }}-arm64
- newrelic/nr-otel-collector:latest-arm64
- '{{ .Env.REGISTRY }}/nr-otel-collector:{{ .Version }}-arm64'
- '{{ .Env.REGISTRY }}/nr-otel-collector:latest-arm64'
extra_files:
- config.yaml
build_flag_templates:
Expand All @@ -110,14 +110,14 @@ dockers:
- --label=org.opencontainers.image.licenses=Apache-2.0
use: buildx
docker_manifests:
- name_template: newrelic/nr-otel-collector:{{ .Version }}
- name_template: '{{ .Env.REGISTRY }}/nr-otel-collector:{{ .Version }}'
image_templates:
- newrelic/nr-otel-collector:{{ .Version }}-amd64
- newrelic/nr-otel-collector:{{ .Version }}-arm64
- name_template: newrelic/nr-otel-collector:latest
- '{{ .Env.REGISTRY }}/nr-otel-collector:{{ .Version }}-amd64'
- '{{ .Env.REGISTRY }}/nr-otel-collector:{{ .Version }}-arm64'
- name_template: '{{ .Env.REGISTRY }}/nr-otel-collector:latest'
image_templates:
- newrelic/nr-otel-collector:latest-amd64
- newrelic/nr-otel-collector:latest-arm64
- '{{ .Env.REGISTRY }}/nr-otel-collector:latest-amd64'
- '{{ .Env.REGISTRY }}/nr-otel-collector:latest-arm64'
blobs:
- bucket: nr-releases
provider: s3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
project_name: nrdot-collector-releases-nightly
release:
disable: "true"
draft: true
builds:
- id: nrdot-collector-host
goos:
Expand Down
22 changes: 11 additions & 11 deletions distributions/nrdot-collector-host/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
project_name: nrdot-collector-releases
release:
disable: "true"
draft: true
builds:
- id: nrdot-collector-host
goos:
Expand Down Expand Up @@ -77,8 +77,8 @@ dockers:
goarch: amd64
dockerfile: Dockerfile
image_templates:
- newrelic/nrdot-collector-host:{{ .Version }}-amd64
- newrelic/nrdot-collector-host:latest-amd64
- '{{ .Env.REGISTRY }}/nrdot-collector-host:{{ .Version }}-amd64'
- '{{ .Env.REGISTRY }}/nrdot-collector-host:latest-amd64'
extra_files:
- config.yaml
build_flag_templates:
Expand All @@ -95,8 +95,8 @@ dockers:
goarch: arm64
dockerfile: Dockerfile
image_templates:
- newrelic/nrdot-collector-host:{{ .Version }}-arm64
- newrelic/nrdot-collector-host:latest-arm64
- '{{ .Env.REGISTRY }}/nrdot-collector-host:{{ .Version }}-arm64'
- '{{ .Env.REGISTRY }}/nrdot-collector-host:latest-arm64'
extra_files:
- config.yaml
build_flag_templates:
Expand All @@ -110,14 +110,14 @@ dockers:
- --label=org.opencontainers.image.licenses=Apache-2.0
use: buildx
docker_manifests:
- name_template: newrelic/nrdot-collector-host:{{ .Version }}
- name_template: '{{ .Env.REGISTRY }}/nrdot-collector-host:{{ .Version }}'
image_templates:
- newrelic/nrdot-collector-host:{{ .Version }}-amd64
- newrelic/nrdot-collector-host:{{ .Version }}-arm64
- name_template: newrelic/nrdot-collector-host:latest
- '{{ .Env.REGISTRY }}/nrdot-collector-host:{{ .Version }}-amd64'
- '{{ .Env.REGISTRY }}/nrdot-collector-host:{{ .Version }}-arm64'
- name_template: '{{ .Env.REGISTRY }}/nrdot-collector-host:latest'
image_templates:
- newrelic/nrdot-collector-host:latest-amd64
- newrelic/nrdot-collector-host:latest-arm64
- '{{ .Env.REGISTRY }}/nrdot-collector-host:latest-amd64'
- '{{ .Env.REGISTRY }}/nrdot-collector-host:latest-arm64'
blobs:
- bucket: nr-releases
provider: s3
Expand Down

0 comments on commit b92d8ea

Please sign in to comment.