Version Packages #4903
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 | |
| on: | |
| push: | |
| # Ignore merge queue branches and all tags | |
| branches-ignore: | |
| - 'gh-readonly-queue/**' | |
| tags-ignore: | |
| - '**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| checks: write | |
| statuses: write | |
| jobs: | |
| release-main: | |
| if: github.ref_name == 'main' | |
| name: Main | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 | |
| with: | |
| # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Node | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.PRIMER_APP_ID_SHARED }} | |
| private-key: ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }} | |
| - name: Create release pull request or publish to npm | |
| id: changesets | |
| # Uses SHA for security hardening | |
| # Currently pointing at a commit for the v1.4.1 tag | |
| # Please keep this up-to-date if you're changing the SHA below | |
| uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba | |
| with: | |
| title: Release tracking | |
| # This expects you to have a script called release which does a build for your packages and calls changeset publish | |
| publish: npm run release | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Upload versions json file | |
| uses: primer/.github/.github/actions/[email protected] | |
| release-candidate: | |
| if: github.ref_name == 'changeset-release/main' | |
| name: Candidate (@next) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 | |
| with: | |
| # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | |
| fetch-depth: 0 | |
| - name: Set up Node | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Publish release candidate | |
| run: | | |
| if [[ -f '.changeset/pre.json' ]]; then | |
| npx changeset pre exit | |
| npx changeset version --snapshot | |
| else | |
| for pkg_json_path in packages/react/package.json packages/styled-react/package.json; do | |
| version=$(jq -r .version $pkg_json_path) | |
| echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" $pkg_json_path )" > $pkg_json_path | |
| done | |
| fi | |
| npx changeset publish --tag next | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Report versions | |
| uses: primer/.github/.github/actions/[email protected] | |
| - name: Upload versions json file | |
| uses: primer/.github/.github/actions/[email protected] | |
| release-canary: | |
| name: Canary | |
| if: github.ref_name != 'main' && github.ref_name != 'changeset-release/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 | |
| with: | |
| # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | |
| fetch-depth: 0 | |
| - name: Set up Node | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build --if-present | |
| - name: Publish canary release | |
| run: | | |
| if [[ -f '.changeset/pre.json' ]]; then | |
| npx changeset pre exit | |
| fi | |
| echo -e "---\n$( jq .name packages/react/package.json ): patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md | |
| npx changeset version --snapshot | |
| npx changeset publish --tag canary | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Report versions | |
| uses: primer/.github/.github/actions/[email protected] | |
| - name: Upload versions json file | |
| uses: primer/.github/.github/actions/[email protected] |