|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + lint-tests-and-dist: |
| 10 | + name: Verify lint, tests and dist |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v6 |
| 15 | + |
| 16 | + - name: Setup Node.js |
| 17 | + uses: actions/setup-node@v6 |
| 18 | + with: |
| 19 | + node-version: 22 |
| 20 | + cache: 'npm' |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: npm ci |
| 24 | + |
| 25 | + - name: Run linter |
| 26 | + run: npm run lint |
| 27 | + |
| 28 | + - name: Run tests |
| 29 | + run: npm test -- --ci |
| 30 | + |
| 31 | + - name: Build dist |
| 32 | + run: npm run build |
| 33 | + |
| 34 | + - name: Verify dist is up to date |
| 35 | + run: | |
| 36 | + if ! git diff --quiet --exit-code dist/; then |
| 37 | + echo "::error::Tagged commit has stale dist/. Re-run bump-version or rebuild and re-tag." |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | +
|
| 41 | + create-github-release: |
| 42 | + name: Create GitHub Release and update major alias |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: lint-tests-and-dist |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + steps: |
| 48 | + - name: Checkout repository |
| 49 | + uses: actions/checkout@v6 |
| 50 | + with: |
| 51 | + token: ${{ secrets.PUBLISH_TOKEN }} |
| 52 | + fetch-depth: 0 |
| 53 | + |
| 54 | + - name: Configure git |
| 55 | + run: | |
| 56 | + git config user.name "github-actions[bot]" |
| 57 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 58 | +
|
| 59 | + - name: Update major version alias |
| 60 | + run: | |
| 61 | + tag="${GITHUB_REF_NAME}" |
| 62 | + major=$(echo "$tag" | sed -E 's/^(v[0-9]+).*/\1/') |
| 63 | + if [ -z "$major" ] || [ "$major" = "$tag" ]; then |
| 64 | + echo "Could not derive major alias from tag '$tag', skipping." |
| 65 | + exit 0 |
| 66 | + fi |
| 67 | + git tag -f "$major" "$tag" |
| 68 | + git push origin "$major" --force |
| 69 | + echo "Moved $major to $tag" |
| 70 | +
|
| 71 | + - name: Create GitHub Release |
| 72 | + run: gh release create "${GITHUB_REF_NAME}" --generate-notes |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }} |
0 commit comments