Merge pull request #41 from trydofor/changeset-release/main #57
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
name: Release | |
on: | |
push: | |
branches: | |
- main | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Release to Npmjs | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
checks: write | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
steps: | |
- name: Checkout ${{ github.ref_name }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v4 | |
name: Cache pnpm store | |
id: cache-sdk-repo | |
with: | |
path: | | |
~/.asdf/ | |
~/.local/share/pnpm/store/ | |
key: asdf-store-${{ runner.os }} | |
- name: Install asdf & tools | |
uses: asdf-vm/actions/install@v3 | |
with: | |
skip_install: ${{ steps.cache-sdk-repo.outputs.cache-hit == 'true' }} | |
- name: Install Dependencies | |
run: | | |
chmod a+x .changeset/bump-top.sh | |
echo "install pnpm-hoist-layer to devDep" | |
pnpm -w i --no-frozen-lockfile --ignore-pnpmfile | |
echo "reset the ci lockfile" | |
git restore pnpm-lock.yaml | |
echo "install all deps by lockfile" | |
pnpm -r i --frozen-lockfile | |
echo "Packaging Envs:" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "- node: $(node -v)" >> $GITHUB_STEP_SUMMARY | |
echo "- pnpm: $(pnpm -v)" >> $GITHUB_STEP_SUMMARY | |
echo "- revi: $(jq -r '.version' package.json)" >> $GITHUB_STEP_SUMMARY | |
- name: Bumping or Release | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
commit: ":bookmark: bumping versions" | |
title: ":rocket: release versions" | |
version: .changeset/bump-top.sh | |
publish: pnpm ver:publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release Report | |
id: report | |
run: | | |
# Get outputs from previous step | |
published='${{ steps.changesets.outputs.published }}' | |
publishedPackages='${{ steps.changesets.outputs.publishedPackages }}' | |
hasChangesets='${{ steps.changesets.outputs.hasChangesets }}' | |
pullRequestNumber='${{ steps.changesets.outputs.pullRequestNumber }}' | |
echo "Publishing Result:" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "- Published: $published" >> $GITHUB_STEP_SUMMARY | |
echo "- Has Changesets: $hasChangesets" >> $GITHUB_STEP_SUMMARY | |
echo "- Pull Request Number: $pullRequestNumber" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "Published Packages:" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
# Format published packages | |
echo "$publishedPackages" | jq -c '.[]' | while read pkg; do | |
name=$(echo $pkg | jq -r '.name') | |
version=$(echo $pkg | jq -r '.version') | |
echo "- Package: $name, Version: $version" >> $GITHUB_STEP_SUMMARY | |
done | |
- name: Release Root Package | |
if: steps.changesets.outputs.published == 'true' | |
run: | | |
pnpm publish --access public | |
name=$(jq -r '.name' package.json) | |
version=$(jq -r '.version' package.json) | |
echo "- Package: $name, Version: $version" >> $GITHUB_STEP_SUMMARY |