prepare-release.yml•1.9 kB
name: Prepare release
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
jobs:
update-package-version-and-push-commit:
runs-on: ubuntu-22.04
if: ${{ startsWith(github.event.release.tag_name, 'v') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTIONS_PUSH_TO_MAIN }}
persist-credentials: true
- name: Update package.json
run: |
version_number=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
yq -i -o=json ".version = \"${version_number}\"" package.json
- name: Update manifest.json
run: |
version_number=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
yq -i -o=json ".version = \"${version_number}\"" manifest.json
- name: Update version.ts
run: |
version_number=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
sed -i "s/export const VERSION = \".*\";/export const VERSION = \"${version_number}\";/" src/version.ts
- name: Commit and push changes
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add package.json manifest.json src/version.ts
git commit -m "Release version '${{ github.event.release.tag_name }}'"
# Fail if there are any uncommitted changes
if [[ -n $(git status --porcelain) ]]; then
echo "Error: Git status is dirty. There are uncommitted changes:"
git status
exit 1
fi
- name: Push changes
uses: ad-m/github-push-action@77c5b412c50b723d2a4fbc6d71fb5723bcd439aa
with:
ssh: true
branch: main