Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
test snapshot command (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vahor authored Aug 27, 2023
1 parent 17eb7c0 commit eb23767
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
110 changes: 110 additions & 0 deletions .github/workflows/snapshot-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# 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@v2
with:
comment-id: ${{ github.event.comment.id }}
reactions: eyes

- 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@v2
with:
comment-id: ${{ github.event.comment.id }}
reactions: confused
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: Run Changeset
id: changeset
run: |
pnpm exec changeset version --snapshot
pnpm run publish:prepare
pnpm exec changeset publish --tag
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
publish: pnpm run publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Format changeset comment
id: format-comment
run: |
changesetComment=$(echo "${{ steps.changesets.outputs.changeset-comment }}" | jq '.[] | "\(.name)@\(.version)"')
echo "changesetComment=$changesetComment" >> $GITHUB_OUTPUT
shell: bash

- name: Send success comment
uses: peter-evans/create-or-update-comment@v2
if: steps.changesets.outputs.published == 'true'
with:
comment-id: ${{ github.event.comment.id }}
reactions: rocket
body: |
@${{ github.actor }} your snapshot release has been published!
```
${{ steps.format-comment.outputs.changesetComment }}
```
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
node_modules
node_modules
.envrc

0 comments on commit eb23767

Please sign in to comment.