chore: Pull before committing version changes (#20) #15
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: CI | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- .editorconfig | |
- .gitignore | |
- CHANGELOG.md | |
- LICENSE.md | |
- README.md | |
jobs: | |
verify: | |
name: Verify | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Check formatting | |
run: test -z "$(go fmt ./...)" | |
- name: Lint source code | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: latest | |
- name: Look for suspicious constructs | |
run: test -z "$(go vet ./...)" | |
- name: Run tests | |
run: go test -cover -v ./... | |
release: | |
name: Release? | |
needs: [ verify ] | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Prepare a release | |
id: release | |
uses: google-github-actions/release-please-action@v4 | |
with: | |
config-file: .github/release-config.json | |
manifest-file: .github/release-manifest.json | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update the version number | |
if: ${{ steps.release.outputs.prs_created == 'true' }} | |
run: | | |
git checkout ${{ fromJSON(steps.release.outputs.pr).headBranchName }} | |
git pull origin ${{ fromJSON(steps.release.outputs.pr).headBranchName }} | |
version=$(jq -r '."."' .github/release-manifest.json) | |
version=${version#v} | |
sed -i '/const semanticVersion = \"v[0-9]*\.[0-9]*\.[0-9]*\"/cconst semanticVersion = \"v$version\"' version.go | |
git config --local user.name "David Letterman" | |
git config --local user.email "48985810+david-letterman@users.noreply.github.com" | |
git add version.go | |
git commit -m "chore: Configure the version number" | |
git push |