From 2bde4f67b8f2da1ede47fa172e88bab8146cc339 Mon Sep 17 00:00:00 2001 From: "Sergio C. Arteaga" Date: Thu, 12 Aug 2021 11:33:52 +0200 Subject: [PATCH] Improve release process (#1480) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergio CastaƱo Arteaga --- .github/workflows/release.yml | 68 ++++++--------------- .gitignore | 1 + .goreleaser.yml | 111 ++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 49 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52f0525f..6a81eaae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,58 +1,28 @@ name: Release on: - release: - types: [published] + push: + tags: + - "v*" jobs: - build-and-publish-docker-images: + release: runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@master + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 - name: Login to Docker Hub - run: echo ${{ secrets.DOCKER_PASS }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin - - name: Extract tag name - id: extract_tag_name - run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - - name: Build hub image - run: | - docker build \ - -f cmd/hub/Dockerfile \ - -t artifacthub/hub:${{steps.extract_tag_name.outputs.tag}} \ - -t artifacthub/hub:latest . - - name: Push hub image - run: docker push --all-tags artifacthub/hub - - name: Build db-migrator image - run: | - docker build \ - -f database/migrations/Dockerfile \ - -t artifacthub/db-migrator:${{steps.extract_tag_name.outputs.tag}} \ - -t artifacthub/db-migrator:latest . - - name: Push db-migrator image - run: docker push --all-tags artifacthub/db-migrator - - name: Build scanner image - run: | - docker build \ - -f cmd/scanner/Dockerfile \ - -t artifacthub/scanner:${{steps.extract_tag_name.outputs.tag}} \ - -t artifacthub/scanner:latest . - - name: Push scanner image - run: docker push --all-tags artifacthub/scanner - - name: Build tracker image - run: | - docker build \ - -f cmd/tracker/Dockerfile \ - -t artifacthub/tracker:${{steps.extract_tag_name.outputs.tag}} \ - -t artifacthub/tracker:latest . - - name: Push tracker image - run: docker push --all-tags artifacthub/tracker - - name: Build ah image - run: | - docker build \ - --build-arg VERSION=${{steps.extract_tag_name.outputs.tag}} \ - --build-arg GIT_COMMIT=$GITHUB_SHA \ - -f cmd/ah/Dockerfile \ - -t artifacthub/ah:${{steps.extract_tag_name.outputs.tag}} \ - -t artifacthub/ah:latest . - - name: Push ah image - run: docker push --all-tags artifacthub/ah + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + - name: Release + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GHT_RELEASE }} diff --git a/.gitignore b/.gitignore index 8395778e..8cdb0d50 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ docs/www/content/topics/* !docs/www/content/topics/annotations docs/www/content/topics/annotations/* !docs/www/content/topics/annotations/_index.md +dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..a54b2830 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,111 @@ +project_name: ah + +release: + name_template: "Artifact Hub {{ .Tag }}" + +snapshot: + name_template: "devel-{{ .ShortCommit }}" + +gomod: + proxy: true + +builds: + - id: ah + binary: ah + main: ./cmd/ah + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + ldflags: + - -X main.version={{ .Version }} + - -X main.gitCommit={{ .FullCommit }} + +archives: + - id: ah + files: + - LICENSE + format: tar.gz + format_overrides: + - goos: windows + format: zip + replacements: + darwin: macos + +dockers: + - dockerfile: cmd/ah/Dockerfile + image_templates: + - "artifacthub/ah:{{ .Tag }}" + - "artifacthub/ah:latest" + build_flag_templates: + - "--build-arg=VERSION={{ .Version }}" + - "--build-arg=GIT_COMMIT={{ .FullCommit }}" + extra_files: + - go.mod + - go.sum + - cmd/ah + - internal + - dockerfile: database/migrations/Dockerfile + image_templates: + - "artifacthub/db-migrator:{{ .Tag }}" + - "artifacthub/db-migrator:latest" + extra_files: + - database/migrations + - dockerfile: cmd/hub/Dockerfile + image_templates: + - "artifacthub/hub:{{ .Tag }}" + - "artifacthub/hub:latest" + extra_files: + - go.mod + - go.sum + - cmd/hub + - docs + - internal + - scripts + - web + - widget + - dockerfile: cmd/scanner/Dockerfile + image_templates: + - "artifacthub/scanner:{{ .Tag }}" + - "artifacthub/scanner:latest" + extra_files: + - go.mod + - go.sum + - cmd/scanner + - internal + - dockerfile: cmd/tracker/Dockerfile + image_templates: + - "artifacthub/tracker:{{ .Tag }}" + - "artifacthub/tracker:latest" + extra_files: + - go.mod + - go.sum + - cmd/tracker + - internal + +brews: + - description: Artifact Hub command line tool + homepage: https://github.com/artifacthub/hub + license: Apache-2.0 + tap: + owner: artifacthub + name: homebrew-cmd + commit_author: + name: artifacthubio + email: hub@artifacthub.io + +scoop: + description: Artifact Hub command line tool + homepage: https://github.com/artifacthub/hub + license: Apache-2.0 + bucket: + owner: artifacthub + name: scoop-cmd + commit_author: + name: artifacthubio + email: hub@artifacthub.io