feat: add localization and stabilize annotation workflow #7
This file contains hidden or 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: Deploy GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: "Version bump" | |
| required: true | |
| default: "auto" | |
| type: choice | |
| options: | |
| - auto | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: github-pages | |
| cancel-in-progress: false | |
| jobs: | |
| version: | |
| name: Prepare SemVer release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.bump.outputs.version }} | |
| tag: ${{ steps.bump.outputs.tag }} | |
| bump: ${{ steps.bump.outputs.bump }} | |
| sha: ${{ steps.bump.outputs.sha }} | |
| build_time: ${{ steps.bump.outputs.build_time }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Calculate and commit next version | |
| id: bump | |
| env: | |
| BUMP_INPUT: ${{ github.event.inputs.bump || 'auto' }} | |
| run: | | |
| set -euo pipefail | |
| git fetch --tags --force | |
| LAST_TAG="$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || true)" | |
| if [ -n "$LAST_TAG" ]; then | |
| BASE_VERSION="${LAST_TAG#v}" | |
| COMMITS="$(git log "${LAST_TAG}..HEAD" --pretty=format:'%s%n%b')" | |
| else | |
| BASE_VERSION="$(node -p "require('./package.json').version || '0.0.0'")" | |
| COMMITS="$(git log --pretty=format:'%s%n%b')" | |
| fi | |
| if [ "$BUMP_INPUT" != "auto" ]; then | |
| BUMP="$BUMP_INPUT" | |
| elif printf '%s\n' "$COMMITS" | grep -Eiq '\[major\]|BREAKING CHANGE|^[a-z]+(\([^)]+\))?!:'; then | |
| BUMP="major" | |
| elif printf '%s\n' "$COMMITS" | grep -Eiq '\[minor\]|^feat(\([^)]+\))?:|^feature(\([^)]+\))?:'; then | |
| BUMP="minor" | |
| else | |
| BUMP="patch" | |
| fi | |
| IFS='.' read -r MAJOR MINOR PATCH <<VERSION_PARTS | |
| $BASE_VERSION | |
| VERSION_PARTS | |
| MAJOR="${MAJOR:-0}" | |
| MINOR="${MINOR:-0}" | |
| PATCH="${PATCH:-0}" | |
| case "$BUMP" in | |
| major) | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| *) | |
| echo "Unknown bump type: $BUMP" | |
| exit 1 | |
| ;; | |
| esac | |
| NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| NEXT_TAG="v${NEXT_VERSION}" | |
| if git rev-parse "$NEXT_TAG" >/dev/null 2>&1; then | |
| echo "Tag already exists: $NEXT_TAG" | |
| exit 1 | |
| fi | |
| npm version "$NEXT_VERSION" --no-git-tag-version --allow-same-version | |
| git add package.json | |
| if [ -f package-lock.json ]; then | |
| git add package-lock.json | |
| fi | |
| git commit -m "chore(release): ${NEXT_TAG} [skip ci]" | |
| git tag -a "$NEXT_TAG" -m "$NEXT_TAG" | |
| git push origin HEAD:main | |
| git push origin "$NEXT_TAG" | |
| BUILD_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | |
| RELEASE_SHA="$(git rev-parse HEAD)" | |
| echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=$NEXT_TAG" >> "$GITHUB_OUTPUT" | |
| echo "bump=$BUMP" >> "$GITHUB_OUTPUT" | |
| echo "sha=$RELEASE_SHA" >> "$GITHUB_OUTPUT" | |
| echo "build_time=$BUILD_TIME" >> "$GITHUB_OUTPUT" | |
| build: | |
| name: Build static PWA | |
| needs: version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout release tag | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ needs.version.outputs.tag }} | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| env: | |
| VITE_APP_VERSION: ${{ needs.version.outputs.version }} | |
| VITE_APP_VERSION_TAG: ${{ needs.version.outputs.tag }} | |
| VITE_APP_BUILD_SHA: ${{ needs.version.outputs.sha }} | |
| VITE_APP_BUILD_TIME: ${{ needs.version.outputs.build_time }} | |
| run: npm run build | |
| - name: Add build version metadata | |
| env: | |
| APP_VERSION: ${{ needs.version.outputs.version }} | |
| APP_VERSION_TAG: ${{ needs.version.outputs.tag }} | |
| APP_VERSION_BUMP: ${{ needs.version.outputs.bump }} | |
| APP_BUILD_SHA: ${{ needs.version.outputs.sha }} | |
| APP_BUILD_TIME: ${{ needs.version.outputs.build_time }} | |
| run: | | |
| node <<'NODE' | |
| const fs = require('fs'); | |
| const versionInfo = { | |
| name: 'auditm-field', | |
| version: process.env.APP_VERSION, | |
| tag: process.env.APP_VERSION_TAG, | |
| bump: process.env.APP_VERSION_BUMP, | |
| sha: process.env.APP_BUILD_SHA, | |
| builtAt: process.env.APP_BUILD_TIME, | |
| }; | |
| fs.writeFileSync('dist/version.json', JSON.stringify(versionInfo, null, 2) + '\n'); | |
| NODE | |
| - name: Add SPA fallback | |
| run: cp dist/index.html dist/404.html | |
| - name: Configure GitHub Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload GitHub Pages artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: dist | |
| deploy: | |
| name: Deploy static PWA | |
| needs: | |
| - version | |
| - build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| page_url: ${{ steps.deployment.outputs.page_url }} | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| release: | |
| name: Create GitHub Release | |
| needs: | |
| - version | |
| - deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout release tag | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ needs.version.outputs.tag }} | |
| fetch-depth: 0 | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_TAG: ${{ needs.version.outputs.tag }} | |
| PAGE_URL: ${{ needs.deploy.outputs.page_url }} | |
| VERSION_BUMP: ${{ needs.version.outputs.bump }} | |
| BUILD_SHA: ${{ needs.version.outputs.sha }} | |
| run: | | |
| gh release create "$RELEASE_TAG" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --target "$BUILD_SHA" \ | |
| --title "$RELEASE_TAG" \ | |
| --notes "AuditM-Field GitHub Pages deployment. | |
| Version bump: $VERSION_BUMP | |
| Commit: $BUILD_SHA | |
| Deployed URL: $PAGE_URL" |