This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
Version Packages #10
This file contains 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
# Based on https://github.com/Shopify/polaris | |
name: Snapshot Release | |
on: | |
issue_comment: | |
types: | |
- created | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
snapshot: | |
name: Snapshot Release | |
runs-on: ubuntu-latest | |
if: | | |
github.event.issue.pull_request && | |
github.event.comment.body == '/snapshot' && | |
github.repository == 'pedakihq/pedaki' | |
steps: | |
- name: Add initial reaction | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: eyes | |
edit-mode: replace | |
body: | | |
@${{ github.actor }} your snapshot release is being processed. | |
:hourglass_flowing_sand: This may take a few minutes... | |
- name: Enforce permission requirement | |
id: check-permissions | |
continue-on-error: true | |
uses: prince-chrismc/check-actor-permissions-action@v2 | |
with: | |
permission: write | |
- name: Add reaction if permission requirement not met | |
if: steps.check-permissions.outcome == 'failure' | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: confused | |
edit-mode: replace | |
body: | | |
@${{ github.actor }} you do not have permission to run this command. | |
Please ask a maintainer to run this command for you. | |
- name: Exit if permission requirement not met | |
if: steps.check-permissions.outcome == 'failure' | |
run: exit 1 | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Because changeset entries are consumed and removed on the | |
# 'changeset-release/main' branch, we need to reset the files | |
# so the following 'changeset version --snapshot' command will | |
# regenerate the package version bumps with the snapshot releases | |
- name: Reset changeset entries on changeset-release/main branch | |
run: | | |
if [[ $(git branch --show-current) == 'changeset-release/main' ]]; then | |
git checkout origin/main -- .changeset | |
fi | |
- uses: pnpm/action-setup@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: .nvmrc | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install deps | |
run: pnpm install --child-concurrency 3 --frozen-lockfile --prefer-offline | |
- name: Create an .npmrc | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
cat << EOF > "$HOME/.npmrc" | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
- name: Run Changeset | |
id: changeset | |
run: | | |
pnpm exec changeset version --snapshot | |
pnpm run publish:prepare | |
output=$(pnpm exec changeset publish --tag next) | |
echo $output | |
changesetComment=$(echo "$output" | grep -zoE 'New tag: ([^ ]+)' | sed -E 's/New tag: //g') | |
echo 'changeset-comment="$changesetComment"\n' >> $GITHUB_OUTPUT | |
echo $changesetComment | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Send success comment | |
uses: peter-evans/create-or-update-comment@v3 | |
if: success() | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: rocket | |
reactions-edit-mode: replace | |
edit-mode: replace | |
body: | | |
@${{ github.actor }} your snapshot release has been published! | |
``` | |
${{ steps.changeset.outputs.changeset-comment }} | |
``` | |
- name: Send failure comment | |
uses: peter-evans/create-or-update-comment@v3 | |
if: failure() | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: -1 | |
reactions-edit-mode: replace | |
edit-mode: replace | |
body: | | |
@${{ github.actor }} your snapshot release failed to publish. | |
Please check the logs for more information. |