Skip to content

Commit

Permalink
Merge pull request #17 from cacoco/cacoco/MetaVersioning
Browse files Browse the repository at this point in the history
[release] More updates for codemeta.json file versioning
  • Loading branch information
cacoco authored Feb 5, 2024
2 parents 9a75819 + c6bedef commit edc427c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/codemeta-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: codemeta-update
defaults:
run:
shell: bash
"on":
workflow_dispatch:
inputs:
release_version:
description: The released version to write into the codemeta.json file
required: true
type: string
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
if: ${{ inputs.release_version }}
steps:
- uses: actions/checkout@v4
- name: Set up Git Config
run: |
git config user.name "goreleaserbot"
git config user.email "<bot@goreleaser.com>"
- name: Update codemeta.json
run: |
# Update the codemeta.json file in main branch with the latest version
git checkout main
echo "`jq '.version="${{ inputs.release_version }}"' codemeta.json`" > codemeta.json
git commit -am "[release] Update codemeta.json version to ${{ inputs.release_version }}"
git push origin main
18 changes: 13 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ jobs:
run: |
git config user.name "goreleaserbot"
git config user.email "<bot@goreleaser.com>"
- name: Update codemeta.json version
- name: Update codemeta.json version in tag
run: |
# updates the codemeta.json file with the tag release version
TAG="${{ github.ref_name }}"
VER="${TAG#v}""
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
git branch ${{ github.ref_name }}-branch
git checkout ${{ github.ref_name }}-branch
echo $(jq ".version=\"$VER\"" codemeta.json) > codemeta.json
git commit -am "Update codemeta.json version"
git push origin ${{ github.ref_name }}-branch # create a branch with the new version for PR on main
echo "`jq '.version="${{ env.VERSION }}"' codemeta.json`" > codemeta.json
git commit -am "[release] Update codemeta.json version"
git tag -d ${{ github.ref_name }}
git tag ${{ github.ref_name }}
git push --delete origin ${{ github.ref_name }}
git push origin ${{ github.ref_name }}
git checkout ${{ github.ref_name }}
git branch -D ${{ github.ref_name }}-branch
- name: Run GoReleaser
Expand All @@ -53,3 +58,6 @@ jobs:
# 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 }}
- name: Run Update CodeMeta JSON file action
run: |
gh workflow run codemeta-version.yaml --field release_version=${{ env.VERSION }} --ref main

0 comments on commit edc427c

Please sign in to comment.