mirror of
https://github.com/jalad25/contact-note.git
synced 2026-07-22 17:10:33 +00:00
62 lines
1.9 KiB
YAML
62 lines
1.9 KiB
YAML
name: Bump version
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "New version (e.g. 1.1.0)"
|
|
required: true
|
|
|
|
jobs:
|
|
bump:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Ensure on master
|
|
run: |
|
|
if [ "$GITHUB_REF" != "refs/heads/master" ]; then
|
|
echo "version-bump must run on master, got $GITHUB_REF"
|
|
exit 1
|
|
fi
|
|
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
token: ${{ secrets.RELEASE_TOKEN }}
|
|
|
|
- name: Validate version format
|
|
run: |
|
|
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
echo "Invalid version format. Expected x.y.z (e.g. 1.1.0)"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Validate version is not already released
|
|
run: |
|
|
if jq -e --arg v "${{ inputs.version }}" 'has($v)' versions.json > /dev/null; then
|
|
echo "versions.json already contains an entry for ${{ inputs.version }}"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Update version files
|
|
run: |
|
|
VERSION="${{ inputs.version }}"
|
|
MIN_APP_VERSION=$(jq -r '.minAppVersion' manifest.json)
|
|
|
|
jq --arg v "$VERSION" '.version = $v' manifest.json > tmp.json && mv tmp.json manifest.json
|
|
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
|
jq --arg v "$VERSION" --arg m "$MIN_APP_VERSION" '.[$v] = $m' versions.json > tmp.json && mv tmp.json versions.json
|
|
|
|
- name: Commit and push tag
|
|
run: |
|
|
VERSION="${{ inputs.version }}"
|
|
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
git add manifest.json package.json versions.json
|
|
git commit -m "Release $VERSION"
|
|
git tag -a "$VERSION" -m "$VERSION"
|
|
git push
|
|
git push origin "$VERSION"
|