From b556057ad5981e9249ffcefe1426e3453b1bf97d Mon Sep 17 00:00:00 2001 From: Yuxin Kang Date: Mon, 27 Feb 2023 17:16:49 -0500 Subject: [PATCH] fix: add release workflow --- .github/workflows/release.yml | 71 ++++++++++++++++++++++++++--------- package.json | 5 ++- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc977ce80..76eeff92b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,30 +1,65 @@ name: Release on: - release: - types: [created] + push: + branches: + - main + workflow_dispatch: + +env: + CI: true + REGISTRY: ghcr.io + +permissions: + contents: write + pull-requests: write + packages: write jobs: - publish: + release: + name: Release runs-on: ubuntu-latest + outputs: + published: ${{ steps.changesets.outputs.published == 'true' }} + + # The published packages output from the changsets action is a stringified JSON array. + # For example: '[{"name":"@labshare/auth","version":"6.6.0"},{"name":"@labshare/auth-ui","version":"3.3.1"}]'. + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} + + strategy: + matrix: + node-version: [18.x] steps: - - uses: actions/checkout@v3 - # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - registry-url: https://registry.npmjs.org + - name: Checkout + uses: actions/checkout@v3 - - run: npm ci - - run: npm publish + - name: Configure CI Github User + run: | + git config --global user.name 'LabShare' + git config --global user.email 'LabShare@labshare.org' + git remote set-url origin https://$GITHUB_ACTOR:$GH_TOKEN@github.com/ncats/auth-monorepo env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + + - run: npm install + with: + npm-token: ${{secrets.NPM_INSTALL_TOKEN}} - - run: npm run typedoc + # Changesets action reuses the .npmrc if it already exists. In this case, we + # need to change to an NPM token with write access. + - run: rm ~/.npmrc + shell: "bash" - - name: Deploy pages - uses: peaceiris/actions-gh-pages@v3 + - name: create and publish versions + id: changesets + uses: changesets/action@v1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/pages + commit: "chore: update versions" + title: "chore: update versions" + publish: npm ci:publish + setupGitUser: false + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + \ No newline at end of file diff --git a/package.json b/package.json index a226765bc..42925c807 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "test": "tsc && jest", "typedoc": "typedoc", "lint": "eslint --max-warnings=0 --cache .", - "prepare": "husky install" + "prepare": "husky install", + "ci:publish": "changeset publish" }, "dependencies": { "crypto-js": "^4.1.1", @@ -45,6 +46,8 @@ "jwt-decode": "^3.1.2" }, "devDependencies": { + "@changesets/changelog-git": "^0.1.13", + "@changesets/cli": "^2.25.0", "@microsoft/api-extractor": "^7.18.10", "@testing-library/jest-dom": "^5.16.5", "@types/crypto-js": "^4.0.2",