From 1ebf9e67a4f0a96cdccb248b8e915ce70b42bd4c Mon Sep 17 00:00:00 2001 From: Marcus Schiesser <mail@marcusschiesser.de> Date: Thu, 25 Apr 2024 11:09:55 +0800 Subject: [PATCH] ci: add release action (#764) --- .github/workflows/lint_on_push_or_pull.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/release.yml | 47 ++++++++++++++++++++++ .github/workflows/test.yml | 12 +++--- CONTRIBUTING.md | 16 +++----- 5 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/lint_on_push_or_pull.yml b/.github/workflows/lint_on_push_or_pull.yml index 96b8eae52..4c406434e 100644 --- a/.github/workflows/lint_on_push_or_pull.yml +++ b/.github/workflows/lint_on_push_or_pull.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5d36ee0a8..6e18f85b7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..eb1b6a71d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v3 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Add auth token to .npmrc file + run: | + cat << EOF >> ".npmrc" + //registry.npmjs.org/:_authToken=$NPM_TOKEN + EOF + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + # update version PR with the latest changesets + version: pnpm new-version + # build package and call changeset publish + publish: pnpm release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd7214ba4..9b25ad911 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + + - uses: pnpm/action-setup@v3 + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -43,7 +45,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -58,7 +60,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -87,7 +89,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -105,7 +107,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@v4 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ad9d9283..955d7d99e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,16 +91,10 @@ Please send a descriptive changeset for each PR. ## Publishing (maintainers only) -To publish a new version of the library, first create a new version: +The [Release Github Action](.github/workflows/release.yml) is automatically generating and updating a +PR called "Version Packages". -```shell -pnpm new-version -``` - -If everything looks good, commit the generated files and release the new version: +This PR will update the `package.json` and `CHANGELOG.md` files of each package according to +the current changesets in the [.changeset](.changeset/) folder. -```shell -pnpm release -git push # push to the main branch -git push --tags -``` +If this PR is merged it will automatically add version tags to the repository and publish the updated packages to NPM. -- GitLab