|
| 1 | +name: Snapshot Release |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: |
| 6 | + - created |
| 7 | + |
| 8 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + |
| 10 | +env: |
| 11 | + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} |
| 12 | + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} |
| 13 | + |
| 14 | +jobs: |
| 15 | + snapshot: |
| 16 | + name: Snapshot Release |
| 17 | + runs-on: buildjet-2vcpu-ubuntu-2204 |
| 18 | + if: github.event.issue.pull_request && github.event.comment.body == '/snapshot' |
| 19 | + steps: |
| 20 | + - name: Add initial comment |
| 21 | + uses: peter-evans/create-or-update-comment@v3 |
| 22 | + with: |
| 23 | + comment-id: ${{ github.event.comment.id }} |
| 24 | + body: | |
| 25 | + Follow snapshot progress [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 26 | + reactions: eyes |
| 27 | + |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + # issue_comment requires us to checkout the branch |
| 31 | + # https://github.com/actions/checkout/issues/331#issuecomment-1120113003 |
| 32 | + - name: Checkout pull request branch |
| 33 | + run: hub pr checkout ${{ github.event.issue.number }} |
| 34 | + env: |
| 35 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Set up environment |
| 38 | + uses: ./.github/actions/setup |
| 39 | + timeout-minutes: 5 |
| 40 | + |
| 41 | + - name: Check if changeset exists |
| 42 | + run: | |
| 43 | + pnpm exec changeset status --since main |
| 44 | +
|
| 45 | + - name: Add final comment (failure) |
| 46 | + if: failure() |
| 47 | + uses: peter-evans/create-or-update-comment@v3 |
| 48 | + with: |
| 49 | + comment-id: ${{ github.event.comment.id }} |
| 50 | + body: | |
| 51 | + :x: A changeset is required to build a snapshot. |
| 52 | + reactions: confused |
| 53 | + |
| 54 | + - name: Publish snapshot release |
| 55 | + run: | |
| 56 | + pnpm exec changeset version --snapshot ${{ github.event.issue.number }} && pnpm install |
| 57 | + pnpm run ci:publish --no-git-tag --snapshot |
| 58 | +
|
| 59 | + - name: Retrieve snapshot version |
| 60 | + run: | |
| 61 | + echo "SNAPSHOT_VERSION=$(npm view @plex/core-logging versions --json | grep 0.0.0-${{ github.event.issue.number }} | sort -r | head -n 1 | cut -d'"' -f 2)" >> $GITHUB_OUTPUT |
| 62 | + id: snapshotVersion |
| 63 | + |
| 64 | + - name: Add final comment |
| 65 | + uses: peter-evans/create-or-update-comment@v3 |
| 66 | + with: |
| 67 | + comment-id: ${{ github.event.comment.id }} |
| 68 | + body: | |
| 69 | + ${{steps.snapshotVersion.outputs.SNAPSHOT_VERSION}} has been published. |
| 70 | + reactions: rocket |
0 commit comments