docs(ci): describe unified release workflow #32
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: Release version | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - package.json | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: auto-release | |
| cancel-in-progress: false | |
| jobs: | |
| verify: | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| outputs: | |
| exists: ${{ steps.version.outputs.exists }} | |
| tag: ${{ steps.version.outputs.tag }} | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: 22 | |
| - name: Read application version | |
| id: version | |
| shell: bash | |
| run: | | |
| VERSION="$(node -p "require('./package.json').version")" | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then | |
| echo "Некорректная версия в package.json: $VERSION" | |
| exit 1 | |
| fi | |
| TAG="v$VERSION" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| if git ls-remote --exit-code --tags origin \ | |
| "refs/tags/$TAG" >/dev/null 2>&1; then | |
| git fetch --no-tags origin "refs/tags/$TAG:refs/tags/$TAG" | |
| TAG_SHA="$(git rev-list -n 1 "$TAG")" | |
| if [[ "$TAG_SHA" != "$GITHUB_SHA" ]]; then | |
| echo "Тег $TAG уже указывает на $TAG_SHA вместо ожидаемого $GITHUB_SHA" | |
| exit 1 | |
| fi | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| echo "Тег $TAG уже существует на ожидаемой ревизии." | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Будет создан тег $TAG." | |
| fi | |
| - name: Verify changelog | |
| shell: bash | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| if ! grep -Eq "^##[[:space:]]+${VERSION}([[:space:]]|—|-|$)" CHANGELOG.md; then | |
| echo "В CHANGELOG.md отсутствует раздел для версии $VERSION" | |
| exit 1 | |
| fi | |
| - name: Enable pnpm | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Audit production dependencies | |
| run: pnpm audit --prod | |
| - name: Install Playwright browser | |
| run: pnpm exec playwright install --with-deps chromium | |
| - name: Lint | |
| run: pnpm lint | |
| - name: Run tests | |
| run: pnpm test | |
| - name: Build site | |
| run: pnpm build | |
| env: | |
| VITE_BASE_PATH: ./ | |
| - name: Verify PWA build | |
| run: pnpm test:pwa | |
| - name: Run production browser E2E | |
| run: pnpm test:e2e | |
| - name: Pack dist | |
| run: | | |
| cd dist | |
| zip -r ../credit-calculator-dist.zip . | |
| - name: Upload verified release artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: release-dist | |
| path: credit-calculator-dist.zip | |
| if-no-files-found: error | |
| - name: Build site for GitHub Pages | |
| run: pnpm build | |
| env: | |
| VITE_BASE_PATH: /${{ github.event.repository.name }}/ | |
| VITE_COMMIT_SHA: ${{ github.sha }} | |
| - name: Verify GitHub Pages PWA build | |
| run: pnpm test:pwa | |
| env: | |
| VITE_BASE_PATH: /${{ github.event.repository.name }}/ | |
| - name: Run GitHub Pages E2E | |
| run: pnpm test:e2e | |
| env: | |
| E2E_BASE_PATH: /${{ github.event.repository.name }}/ | |
| - name: Upload GitHub Pages artifact | |
| uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 | |
| with: | |
| path: ./dist | |
| publish: | |
| needs: verify | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository for tag publication | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Create and push Git tag | |
| if: needs.verify.outputs.exists == 'false' | |
| shell: bash | |
| env: | |
| TAG: ${{ needs.verify.outputs.tag }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email \ | |
| "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$TAG" "$GITHUB_SHA" -m "Release $TAG" | |
| git push origin "$TAG" | |
| - name: Download verified release artifact | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| name: release-dist | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 | |
| with: | |
| tag_name: ${{ needs.verify.outputs.tag }} | |
| files: credit-calculator-dist.zip | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| overwrite_files: true | |
| android: | |
| needs: | |
| - verify | |
| - publish | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/android-release.yml | |
| with: | |
| tag: ${{ needs.verify.outputs.tag }} | |
| run_source_checks: false | |
| secrets: inherit | |
| deploy-pages: | |
| needs: | |
| - verify | |
| - publish | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Configure GitHub Pages | |
| uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 | |
| - name: Deploy site | |
| id: deployment | |
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 |