Merge pull request #12 from frectonz/changeset-release/release-0.1 #9
Workflow file for this run
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: Prerelease | |
| on: | |
| push: | |
| branches: | |
| - "release-*" | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| env: | |
| PRE_TAG: 'next' | |
| EXIT_PRERELEASE_COMMIT_MSG: 'Exit prerelease' | |
| VERSION_PR_COMMIT_PREFIX: 'Version Packages' | |
| jobs: | |
| prerelease: | |
| name: Changesets Prerelease | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.APP_ID }} | |
| private-key: ${{ secrets.PRIVATE_KEY }} | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| fetch-depth: 0 | |
| - uses: DeterminateSystems/nix-installer-action@main | |
| - uses: DeterminateSystems/magic-nix-cache-action@main | |
| - name: Install deps | |
| run: nix develop -c pnpm install --frozen-lockfile | |
| - name: Check for pre.json file existence | |
| id: check_files | |
| uses: andstor/file-existence-action@v3 | |
| with: | |
| files: ".changeset/pre.json" | |
| - name: Get GitHub App User ID | |
| id: get-user-id | |
| run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Enter prerelease mode | |
| if: steps.check_files.outputs.files_exists == 'false' && !contains(github.event.head_commit.message, env.EXIT_PRERELEASE_COMMIT_MSG) | |
| run: | | |
| git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | |
| git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' | |
| nix develop -c pnpm changeset pre enter ${{ env.PRE_TAG }} | |
| git add -A | |
| git commit -m 'Enter prerelease mode' | |
| git push | |
| - name: Create prerelease PR | |
| if: steps.check_files.outputs.files_exists == 'true' && !startsWith(github.event.head_commit.message, env.VERSION_PR_COMMIT_PREFIX) | |
| uses: changesets/action@v1 | |
| with: | |
| version: nix develop -c pnpm run version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to npm + GitHub | |
| id: changesets | |
| if: steps.check_files.outputs.files_exists == 'true' && contains(github.event.head_commit.message, 'changeset-release/') | |
| uses: changesets/action@v1 | |
| with: | |
| version: echo "This step should never version" | |
| publish: nix develop -c pnpm run release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |