Skip to content

Commit

Permalink
ci: automatic public via changeset in GA
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Oct 6, 2024
1 parent fe59fc8 commit 7f58faf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 42 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- main
paths:
- ".changeset/**.md"
- ".github/workflows/release.yml"

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand All @@ -12,10 +15,19 @@ env:
default_pnpm_version: "latest"
artifact_name: build_${{ github.sha }}

permissions:
contents: read

jobs:
release:
permissions:
contents: write
pull-requests: write
id-token: write
name: Release
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand All @@ -31,8 +43,37 @@ jobs:
- name: Install Dependencies
run: pnpm i

- name: Create Release Pull Request
- name: Create Release Pull Request or Publish to npm
id: changesets_action
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: "pnpm run publish-packages"
commit: "release: Version Packages"
title: "release: Version Packages"
setupGitUser: true
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Generate SUMMARY
env:
hasChangesets: ${{steps.changesets_action.outputs.hasChangesets}}
pullRequestNumber: ${{steps.changesets_action.outputs.pullRequestNumber}}
published: ${{steps.changesets_action.outputs.published}}
publishedPackages: ${{steps.changesets_action.outputs.publishedPackages}}
run: |
echo "## changesets/action" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "|name|value|" >> $GITHUB_STEP_SUMMARY
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
echo "|hasChangesets|${{env.hasChangesets}}|" >> $GITHUB_STEP_SUMMARY
echo "|pullRequestNumber|${{github.repository}}#${{env.pullRequestNumber}}|" >> $GITHUB_STEP_SUMMARY
echo "|published|${{env.published}}|" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### published packages:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "${{env.publishedPackages.*.name}}" >> $GITHUB_STEP_SUMMARY
echo "${{env.publishedPackages.*.version}}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"dev": "turbo dev",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo lint",
"prepack": "echo \"don't run pack/publish in root!\" && exit 1",
"prepare": "turbo run build -F eslint-config",
"publish-packages": "turbo run build && changeset publish",
"sort": "pnpm -r exec sort-package-json && sort-package-json",
"test": "turbo test",
"test:lcov": "turbo test:lcov"
Expand Down

0 comments on commit 7f58faf

Please # to comment.