From ffc44d63913dcff4d86244df3247d7a60ef43c85 Mon Sep 17 00:00:00 2001 From: yue Date: Tue, 26 Sep 2023 16:23:20 +0900 Subject: [PATCH] feat: add publish action --- .github/workflows/publish.yml | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..d5012a3f8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,68 @@ +name: Publish to npmjs + +on: + # Who has permission to workflow_dispatch + # https://github.com/orgs/community/discussions/26622 + workflow_dispatch: + inputs: + version: + description: 'Version to release' + required: true + +jobs: + fetch: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # checkout is pinned to dev branch here + ref: dev + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: './.node-version' + - name: Cache Deps + uses: actions/cache@v3 + with: + path: | + node_modules + packages/*/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles( 'yarn.lock' ) }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Fetch Deps + run: yarn install --frozen-lockfile + + publish: + runs-on: ubuntu-latest + needs: fetch + permissions: + contents: write + id-token: write + steps: + - name: Set git username and email + run: | + git config --local user.email "action@github.com" + git config --local user.name "actions-user" + + - name: Set package version + run: | + yarn lerna version ${{ github.event.inputs.version }} --exact --no-push --yes + yarn lerna publish from-git --dist-tag latest + env: + NPM_CONFIG_PROVENANCE: true + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Git push version up commits + run: | + git push origin ${{ github.ref_name }} + + - name: Upload Builds + uses: actions/upload-artifact@v3 + with: + name: build + path: | + packages/*/lib/ + packages/*/types/ + packages/*/ts*/