|
1 | 1 | name: Release |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | | - branches: |
5 | | - - 'main' |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + cancel-in-progress: true |
| 10 | + |
| 11 | +permissions: |
| 12 | + id-token: write # Required for OIDC |
| 13 | + contents: read |
| 14 | + checks: write |
| 15 | + statuses: write |
| 16 | + |
6 | 17 | jobs: |
7 | | - release: |
8 | | - name: Final |
9 | | - if: ${{ github.repository == 'primer/stylelint-config' }} |
| 18 | + release-main: |
| 19 | + name: Main |
| 20 | + if: ${{ github.repository == 'primer/stylelint-config' && github.ref_name == 'main' }} |
10 | 21 |
|
11 | 22 | runs-on: ubuntu-latest |
12 | 23 | steps: |
|
15 | 26 | with: |
16 | 27 | # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits |
17 | 28 | fetch-depth: 0 |
18 | | - persist-credentials: false |
19 | 29 |
|
20 | 30 | - name: Set up Node.js |
21 | 31 | uses: actions/setup-node@v5 |
|
30 | 40 | title: Release Tracking |
31 | 41 | # This expects you to have a script called release which does a build for your packages and calls changeset publish |
32 | 42 | publish: npm run release |
| 43 | + |
| 44 | + release-canary: |
| 45 | + name: Canary |
| 46 | + if: ${{ github.repository == 'primer/stylelint-config' && github.ref_name != 'main' && github.ref_name != 'changeset-release/main' }} |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - name: Checkout repository |
| 50 | + uses: actions/checkout@v5 |
| 51 | + with: |
| 52 | + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits |
| 53 | + fetch-depth: 0 |
| 54 | + |
| 55 | + - name: Set up Node |
| 56 | + uses: actions/setup-node@v6 |
| 57 | + with: |
| 58 | + node_version: 24 |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: npm ci |
| 62 | + |
| 63 | + - name: Build |
| 64 | + run: npm run build --if-present |
| 65 | + |
| 66 | + - name: Publish canary release |
| 67 | + run: | |
| 68 | + echo "$( jq '.version = "0.0.0"' package.json )" > package.json |
| 69 | + echo -e "---\n$( jq .name package.json ): patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md |
| 70 | + npx changeset version --snapshot |
| 71 | + npx changeset publish --tag canary |
33 | 72 | env: |
34 | | - GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }} |
35 | | - NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }} |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + - name: Output canary version |
| 76 | + uses: actions/github-script@v8 |
| 77 | + with: |
| 78 | + script: | |
| 79 | + const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`) |
| 80 | + github.rest.repos.createCommitStatus({ |
| 81 | + owner: context.repo.owner, |
| 82 | + repo: context.repo.repo, |
| 83 | + sha: context.sha, |
| 84 | + state: 'success', |
| 85 | + context: `Published ${package.name}`, |
| 86 | + description: package.version, |
| 87 | + target_url: `https://unpkg.com/${package.name}@${package.version}/` |
| 88 | + }) |
| 89 | + - uses: primer/.github/.github/actions/upload-versions@main |
0 commit comments