Automate manifest.json version updates during release #9
@@ -17,9 +17,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Validate version format
|
- name: Validate version format
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
|
||||||
echo "::error::Invalid version format '${{ inputs.version }}'. Use X.X.X (e.g., 1.2.3)"
|
echo "::error::Invalid version format '$VERSION'. Use X.X.X (e.g., 1.2.3)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -27,9 +29,11 @@ jobs:
|
|||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Check tag does not already exist
|
- name: Check tag does not already exist
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
if git ls-remote --tags origin "refs/tags/v${{ inputs.version }}" | grep -q .; then
|
if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then
|
||||||
echo "::error::Tag v${{ inputs.version }} already exists"
|
echo "::error::Tag v${VERSION} already exists"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|||||||
|
|
||||||
@@ -42,14 +46,18 @@ jobs:
|
|||||||
run: go test -race ./...
|
run: go test -race ./...
|
||||||
|
|
||||||
- name: Update manifest.json version
|
- name: Update manifest.json version
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
sed -i 's/"version": *"[^"]*"/"version": "${{ inputs.version }}"/' manifest.json
|
jq --arg v "$VERSION" '.version = $v' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
|
||||||
|
|
||||||
- name: Commit, tag, and push
|
- name: Commit, tag, and push
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git add manifest.json
|
git add manifest.json
|
||||||
git commit --allow-empty -m "Release v${{ inputs.version }}"
|
git commit --allow-empty -m "Release v${VERSION}"
|
||||||
git tag "v${{ inputs.version }}"
|
git tag "v${VERSION}"
|
||||||
git push origin main "v${{ inputs.version }}"
|
git push origin main "v${VERSION}"
|
||||||
|
|||||||
Reference in New Issue
Block a user
This step runs
git ls-remote ... origin ...before the repository is checked out, so it will fail with “not a git repository” / nooriginremote. Move the “Check out code” step before this, or use the GitHub API to check for an existing tag.