Merge pull request #38 from cacoco/setFixes #31
Workflow file for this run
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: release | |
"on": | |
push: | |
tags: | |
- "*" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
jobs: | |
codemeta-update-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Import GPG key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
git_committer_name: ${{ secrets.GIT_COMMITTER_NAME }} | |
git_committer_email: ${{ secrets.GIT_COMMITTER_EMAIL }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Get release version from current tag | |
run: | | |
tag="${{ github.ref_name }}" | |
echo "release-version=${tag#v}" >> $GITHUB_ENV | |
- name: Update codemeta.json version in tag | |
uses: jossef/action-set-json-field@v2.1 | |
with: | |
file: codemeta.json | |
field: version | |
value: "${{ env.release-version }}" | |
- name: Commit updated codemeta.json file on current tag | |
run: | | |
# save the codemeta.json file changes to the current tag | |
git branch ${{ github.ref_name }}-branch | |
git checkout ${{ github.ref_name }}-branch | |
# commit changes | |
git commit -am "[release] Update codemeta.json version to ${{ env.release-version }}" | |
# delete and recreate tag with the above commit | |
git tag -d ${{ github.ref_name }} | |
git tag ${{ github.ref_name }} | |
# push the recreated tag to origin | |
git push --delete origin ${{ github.ref_name }} | |
git push origin ${{ github.ref_name }} | |
# delete the temporary branch | |
git checkout ${{ github.ref_name }} | |
git branch -D ${{ github.ref_name }}-branch | |
goreleaser: | |
runs-on: ubuntu-latest | |
needs: [codemeta-update-tag] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Import GPG key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
# need to push to cacoco/homebrew-tap; use CACOCO_TOKEN instead of default GITHUB_TOKEN | |
GITHUB_TOKEN: ${{ secrets.CACOCO_TOKEN }} | |
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | |
codemeta-update-main: | |
runs-on: ubuntu-latest | |
needs: [goreleaser] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # allows us to access all refs | |
- name: Get release version from current tag | |
run: | | |
tag="${{ github.ref_name }}" | |
echo "release-version=${tag#v}" >> $GITHUB_ENV | |
- name: Update codemeta.json version in main branch | |
uses: jossef/action-set-json-field@v2.1 | |
with: | |
file: codemeta.json | |
field: version | |
value: "${{ env.release-version }}" | |
- name: Import GPG key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
git_committer_name: ${{ secrets.GIT_COMMITTER_NAME }} | |
git_committer_email: ${{ secrets.GIT_COMMITTER_EMAIL }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Commit updated codemeta.json file on main branch | |
run: | | |
git checkout main | |
git commit -am "[release] Update codemeta.json version to ${{ env.release-version }}" | |
git push origin main |