Skip to content

Commit

Permalink
Update release workflow (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
micnncim authored Feb 7, 2021
1 parent 8d692bb commit d5bc82f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 70 deletions.
61 changes: 0 additions & 61 deletions .github/workflows/docker.yml

This file was deleted.

77 changes: 68 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,112 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

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

- uses: actions-ecosystem/action-get-merged-pull-request@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
buildkitd-flags: --debug

- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx/cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Get pull request
uses: actions-ecosystem/action-get-merged-pull-request@v1
id: get-merged-pull-request
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions-ecosystem/action-release-label@v1
- name: Get release label
uses: actions-ecosystem/action-release-label@v1
id: release-label
if: ${{ steps.get-merged-pull-request.outputs.title != null }}
with:
labels: ${{ steps.get-merged-pull-request.outputs.labels }}

- uses: actions-ecosystem/action-get-latest-tag@v1
- name: Get latest Git tag
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
if: ${{ steps.release-label.outputs.level != null }}
with:
semver_only: true

- uses: actions-ecosystem/action-bump-semver@v1
- name: Bump up version
uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
if: ${{ steps.release-label.outputs.level != null }}
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: ${{ steps.release-label.outputs.level }}

- uses: actions-ecosystem/action-push-tag@v1
- name: Push new Git tag
uses: actions-ecosystem/action-push-tag@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ steps.get-merged-pull-request.outputs.number }} ${{ steps.get-merged-pull-request.outputs.title }}"

- uses: goreleaser/goreleaser-action@v2
- name: Release binaries with GoReleaser
uses: goreleaser/goreleaser-action@v2
if: ${{ steps.release-label.outputs.level == 'major' || steps.release-label.outputs.level == 'minor' || steps.release-label.outputs.level == 'patch' }}
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions-ecosystem/action-create-comment@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
push: true
cache-from: type=local,src=/tmp/.buildx/cache
cache-to: type=local,dest=/tmp/.buildx/cache,mode=max
tags: |
${{ github.repository }}:latest
${{ github.repository }}:${{ steps.bump-semver.outputs.new_version }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ steps.bump-semver.outputs.new_version }}
- name: Post release comment
uses: actions-ecosystem/action-create-comment@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit d5bc82f

Please sign in to comment.