From 819ac7591aea4653ed98eded9db401d72cb80ca9 Mon Sep 17 00:00:00 2001 From: Lorenzo Fontana Date: Fri, 26 Jul 2024 17:38:10 +0200 Subject: [PATCH] build: release pipeline --- .github/workflows/build.yml | 11 ++++------ .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ .goreleaser.yaml | 10 ++++----- CONTRIBUTING.md | 23 ++++++++++++-------- Makefile | 5 ++--- 5 files changed, 65 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a3f3ac..db57870 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,21 +8,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Login to Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 + - uses: actions/setup-go@v5 with: - registry: public.cr.seqera.io - username: public-cr-admin - password: ${{ secrets.SEQERA_PUBLIC_CR_PASSWORD }} + go-version: "1.22.2" - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Install GoReleaser + - name: Install goreleaser uses: goreleaser/goreleaser-action@v6 with: version: "~> v2" + distribution: goreleaser install-only: true - name: Build snapshot run: make snapshot diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b7f5660 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - "*" + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: "1.22.2" + - name: Login to Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: public.cr.seqera.io + username: public-cr-admin + password: ${{ secrets.SEQERA_PUBLIC_CR_PASSWORD }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Release + uses: goreleaser/goreleaser-action@v6 + with: + version: "~> v2" + distribution: goreleaser + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e295f6c..d90def1 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -13,13 +13,13 @@ builds: # build container images dockers: - image_templates: - - "public.cr.seqera.io/seqeralabs/staticreg:{{ if .IsSnapshot }}{{.ShortCommit}}-snapshot{{ else }}{{ .Tag }}{{ end }}-amd64" + - "public.cr.seqera.io/seqeralabs/staticreg:{{.Tag}}-amd64" use: buildx build_flag_templates: - "--pull" - "--platform=linux/amd64" - image_templates: - - "public.cr.seqera.io/seqeralabs/staticreg:{{ if .IsSnapshot }}{{.ShortCommit}}-snapshot{{ else }}{{ .Tag }}{{ end }}-arm64" + - "public.cr.seqera.io/seqeralabs/staticreg:{{.Tag}}-arm64" use: buildx build_flag_templates: - "--pull" @@ -28,10 +28,10 @@ dockers: # merge multi arch image manifests docker_manifests: - - name_template: "public.cr.seqera.io/seqeralabs/staticreg:{{ if .IsSnapshot }}{{.ShortCommit}}-snapshot{{ else }}{{ .Tag }}{{ end }}" + - name_template: "public.cr.seqera.io/seqeralabs/staticreg:{{.Tag}}" image_templates: - - "public.cr.seqera.io/seqeralabs/staticreg:{{ if .IsSnapshot }}{{.ShortCommit}}-snapshot{{ else }}{{ .Tag }}{{ end }}-amd64" - - "public.cr.seqera.io/seqeralabs/staticreg:{{ if .IsSnapshot }}{{.ShortCommit}}-snapshot{{ else }}{{ .Tag }}{{ end }}-arm64" + - "public.cr.seqera.io/seqeralabs/staticreg:{{.Tag}}-amd64" + - "public.cr.seqera.io/seqeralabs/staticreg:{{.Tag}}-arm64" archives: - format: tar.gz name_template: >- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 574ff69..045815d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,26 +37,31 @@ make ``` -## Manual Release to GitHub +## Release +Releasing is done via GitHub actions. -**NB**: This is only done manually in case the GH action does not work. +To release you need to: -Export a `GITHUB_TOKEN`, generate it from [here](https://github.com/settings/tokens/new?scopes=repo,write:packages) with `write:packages` permissions. +- Bump version in the `VERSION` file (this needs to be a [semver](https://semver.org/) numbers) +- Commit the version file +- Start the release process - -**Release** - -Bump version in the `VERSION` file (this needs to be a [semver](https://semver.org/) numbers) - +**Bump version file** ```bash git checkout master echo "" > VERSION +``` + +**Commit the version file** +```bash git commit -am "release: v$(cat VERSION)" git push ``` -Then you can either release: + + +**Start the release process** ```bash make release diff --git a/Makefile b/Makefile index 5ecf24a..1e0eabd 100644 --- a/Makefile +++ b/Makefile @@ -38,9 +38,8 @@ endif .PHONY: release release: - git tag -a "v$(VERSION)" -m "v$(VERSION)" - git push origin v$(VERSION) - $(GORELEASER_CMD) release --clean --fail-fast + git tag -a "$(VERSION)" -m "$(VERSION)" + git push origin $(VERSION) .PHONY: snapshot snapshot: