Improve release process (#1480)

Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
This commit is contained in:
Sergio C. Arteaga 2021-08-12 11:33:52 +02:00 committed by GitHub
parent 01776bc2b1
commit 2bde4f67b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 131 additions and 49 deletions

View File

@ -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 }}

1
.gitignore vendored
View File

@ -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

111
.goreleaser.yml Normal file
View File

@ -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