fix: promoting release to an environment where it's missing (#34) #129
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Test and Publish | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
on: | |
push: | |
branches: ["master"] | |
paths-ignore: | |
- "CHANGELOG.md" | |
pull_request: | |
branches: ["master"] | |
jobs: | |
test-and-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Go environment | |
uses: actions/setup-go@v3.3.1 | |
with: | |
go-version-file: go.mod | |
# Used to specify whether caching is needed. Set to true, if you'd like to enable caching. | |
cache: true | |
# Used to specify the path to a dependency file - go.sum | |
cache-dependency-path: go.sum | |
- name: Setup dependencies | |
run: make setup | |
- name: Run tests w/ Coverage | |
run: make test-cov | |
- name: Build cli binary | |
run: make build | |
publish: | |
needs: | |
- test-and-build | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
fetch-depth: 0 | |
- name: Setup Go environment | |
uses: actions/setup-go@v3.3.1 | |
with: | |
go-version-file: go.mod | |
# Used to specify whether caching is needed. Set to true, if you'd like to enable caching. | |
cache: true | |
# Used to specify the path to a dependency file - go.sum | |
cache-dependency-path: go.sum | |
- name: Generate changelog and tag release | |
id: changelog | |
uses: TriPSs/conventional-changelog-action@v4 | |
with: | |
input-file: CHANGELOG.md | |
output-file: CHANGELOG.md | |
fallback-version: 0.0.0 | |
skip-commit: true | |
skip-version-file: true | |
skip-tag: true | |
git-push: false | |
- name: Write changelog to temp file for goreleaser | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
run: echo "${{ steps.changelog.outputs.clean_changelog }}" > ${{ runner.temp }}/CHANGELOG.md | |
- name: Commit release | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "chore(release): ${{ steps.changelog.outputs.tag }}" | |
- name: Tag commit | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
run: git tag ${{ steps.changelog.outputs.tag }} | |
- name: Push changelog | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
run: | | |
git push origin master | |
- name: Release new CLI version | |
if: ${{ steps.changelog.outputs.skipped == 'false' }} | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
version: latest | |
args: release --clean --release-notes "${{ runner.temp }}/CHANGELOG.md" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_HOMEBREW_PUBLISHER }} |