diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 6713e8c..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Docker - -on: - push: - tags: - - v[0-9]+.[0-9]+.[0-9]+ - -jobs: - docker: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - 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 Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx/cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - 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: Output version - id: version - run: | - echo ::set-output name=version::${GITHUB_REF##*/} - - - name: Build and push - 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.version.outputs.version }} - ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3dc39d..0cd50ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,45 +9,78 @@ 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 @@ -55,7 +88,33 @@ jobs: 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 }}