From 670c98d47d559219a5410d160fe8d08af819c1a4 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 24 Apr 2024 20:21:20 +0200 Subject: [PATCH] Go auto release workflows (#25) * Update workflows to go-auto-release * Update workflows to go-auto-release --- .github/auto-release.yml | 54 --------------------- .github/workflows/auto-release.yml | 15 ------ .github/workflows/docker-promote.yml | 31 ++++++++++++ .github/workflows/docker.yml | 25 ---------- .github/workflows/feature-branch.yml | 57 ++++++++++++++++++++--- .github/workflows/release.yml | 37 ++++----------- .github/workflows/validate-codeowners.yml | 2 +- .goreleaser.yaml => dev.goreleaser.yaml | 0 8 files changed, 91 insertions(+), 130 deletions(-) delete mode 100644 .github/auto-release.yml delete mode 100644 .github/workflows/auto-release.yml create mode 100644 .github/workflows/docker-promote.yml delete mode 100644 .github/workflows/docker.yml rename .goreleaser.yaml => dev.goreleaser.yaml (100%) diff --git a/.github/auto-release.yml b/.github/auto-release.yml deleted file mode 100644 index b45efb7..0000000 --- a/.github/auto-release.yml +++ /dev/null @@ -1,54 +0,0 @@ -name-template: 'v$RESOLVED_VERSION' -tag-template: '$RESOLVED_VERSION' -version-template: '$MAJOR.$MINOR.$PATCH' -version-resolver: - major: - labels: - - 'major' - minor: - labels: - - 'minor' - - 'enhancement' - patch: - labels: - - 'auto-update' - - 'patch' - - 'fix' - - 'bugfix' - - 'bug' - - 'hotfix' - - 'no-release' - default: 'minor' - -categories: -- title: '🚀 Enhancements' - labels: - - 'enhancement' - - 'patch' -- title: '🐛 Bug Fixes' - labels: - - 'fix' - - 'bugfix' - - 'bug' - - 'hotfix' -- title: '🤖 Automatic Updates' - labels: - - 'auto-update' - -change-template: | -
- $TITLE @$AUTHOR (#$NUMBER) - - $BODY -
- -template: | - $CHANGES - -replacers: -# Remove irrelevant information from Renovate bot -- search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm' - replace: '' -# Remove Renovate bot banner image -- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm' - replace: '' diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml deleted file mode 100644 index 0929676..0000000 --- a/.github/workflows/auto-release.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: auto-release - -on: - push: - branches: - - main - - master - - production - -jobs: - auto: - uses: cloudposse/.github/.github/workflows/shared-auto-release.yml@main - with: - publish: true - secrets: inherit diff --git a/.github/workflows/docker-promote.yml b/.github/workflows/docker-promote.yml new file mode 100644 index 0000000..da2d7d2 --- /dev/null +++ b/.github/workflows/docker-promote.yml @@ -0,0 +1,31 @@ +name: Docker Promote + +on: + push: + tags: + - "*" + +permissions: + contents: read + packages: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + ci-docker: + runs-on: ubuntu-latest + steps: + - uses: cloudposse/github-action-docker-promote@0.3.0 + id: promote + with: + registry: ghcr.io + organization: "${{ github.event.repository.owner.login }}" + repository: "${{ github.event.repository.name }}" + login: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + platforms: linux/amd64,linux/arm64 + from: sha-${{ github.sha }} + to: ${{ github.event.release.tag_name }} + use_metadata: false \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 4482f84..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "docker" -on: - push: - branches: - - master - pull_request: - types: [opened, synchronize, reopened] - release: - types: - - created -jobs: - build-and-push: - runs-on: ubuntu-latest - steps: - - name: "Checkout source code at current commit" - uses: actions/checkout@v2 - - name: "Build and push docker image to DockerHub" - uses: docker/build-push-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - repository: ${{ github.repository }} - registry: registry-1.docker.io - tag_with_ref: true - tag_with_sha: true diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml index f94fa98..e1ef782 100644 --- a/.github/workflows/feature-branch.yml +++ b/.github/workflows/feature-branch.yml @@ -9,30 +9,73 @@ on: - synchronize - reopened + push: + branches: + - main + - release/v* + paths-ignore: + - '.github/**' + - 'docs/**' + - 'examples/**' + - 'test/**' + +permissions: + contents: read + packages: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + jobs: - build: + ci-go: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version-file: go.mod - name: Test Snapshot Release - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: distribution: goreleaser version: latest - args: release --clean --snapshot + args: release --config ./dev.goreleaser.yaml --clean --snapshot - name: Upload Test Release Assets - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: github-status-updater path: dist/* retention-days: 3 + + ci-docker: + runs-on: ubuntu-latest + steps: + - name: "Checkout source code at current commit" + uses: actions/checkout@v4 + + - name: Build + id: build + uses: cloudposse/github-action-docker-build-push@1.15.1 + with: + registry: ghcr.io + organization: "${{ github.event.repository.owner.login }}" + repository: "${{ github.event.repository.name }}" + login: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + platforms: linux/amd64,linux/arm64 + + release: + if: github.event_name == 'push' + needs: [ci-go, ci-docker] + uses: cloudposse/.github/.github/workflows/shared-go-auto-release.yml@main + with: + publish: true + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e1a769..178c027 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,15 @@ name: Release - on: - workflow_dispatch: - release: - types: - - published + types: [published] -permissions: - contents: write +permissions: {} -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '1.20' - - - name: Public Release - uses: goreleaser/goreleaser-action@v4 - with: - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +jobs: + perform: + uses: cloudposse/.github/.github/workflows/shared-release-branches.yml@main + secrets: inherit diff --git a/.github/workflows/validate-codeowners.yml b/.github/workflows/validate-codeowners.yml index 70f829e..cc1e159 100644 --- a/.github/workflows/validate-codeowners.yml +++ b/.github/workflows/validate-codeowners.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Checkout source code at current commit" - uses: actions/checkout@v2 + uses: actions/checkout@v4 - uses: mszostok/codeowners-validator@v0.7.1 if: github.event.pull_request.head.repo.full_name == github.repository name: "Full check of CODEOWNERS" diff --git a/.goreleaser.yaml b/dev.goreleaser.yaml similarity index 100% rename from .goreleaser.yaml rename to dev.goreleaser.yaml