|
| 1 | +name: Prerelease |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + # Target release-x.x branches |
| 7 | + - "release-*" |
| 8 | + |
| 9 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + prerelease: |
| 13 | + name: Changesets Prerelease |
| 14 | + # Prevents changesets action from creating a PR on forks |
| 15 | + if: github.repository == 'apollographql/apollo-client' |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout repo |
| 19 | + uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + # Fetch entire git history so Changesets can generate changelogs |
| 22 | + # with the correct commits |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Append NPM token to .npmrc |
| 26 | + run: | |
| 27 | + cat << EOF > "$HOME/.npmrc" |
| 28 | + //registry.npmjs.org/:_authToken=$NPM_TOKEN |
| 29 | + EOF |
| 30 | + env: |
| 31 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 32 | + |
| 33 | + - name: Setup Node.js 18.x |
| 34 | + uses: actions/setup-node@v2 |
| 35 | + with: |
| 36 | + node-version: 18.x |
| 37 | + |
| 38 | + - name: Install dependencies with cache |
| 39 | + uses: bahmutov/npm-install@v1 |
| 40 | + |
| 41 | + - name: Enter prerelease mode |
| 42 | + # if .changeset/pre.json does not exist and we did not recently exit |
| 43 | + # prerelease mode, enter prerelease mode with tag alpha |
| 44 | + run: | |
| 45 | + [ ! -f .changeset/pre.json && !contains(github.event.head_commit.message, 'Exit prerelease') ] \ |
| 46 | + && npx changeset pre enter alpha \ |
| 47 | + || echo 'Already in pre mode or recently exited' |
| 48 | +
|
| 49 | + - name: Create release PR |
| 50 | + id: changesets |
| 51 | + uses: changesets/action@v1 |
| 52 | + with: |
| 53 | + version: npm run changeset-version |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + - name: Publish alpha to npm |
| 58 | + if: "! test -f .changeset/pre.json" |
| 59 | + run: npm run changeset-publish |
| 60 | + |
| 61 | + # - name: Send a Slack notification on Publish |
| 62 | + # if: steps.changesets.outputs.published == 'true' |
| 63 | + # run: echo "Send message to Slack" |
0 commit comments