Skip to content

Commit

Permalink
Merge pull request #1297 from pixiv/feat/add-publish-action
Browse files Browse the repository at this point in the history
feature: add publish action
  • Loading branch information
yue4u committed Sep 27, 2023
2 parents 71fa8c9 + 42d5348 commit b3d3a61
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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
type: string
distTag:
description: 'Used as lerna publish --dist-tag'
default: 'latest'
required: true
type: string

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 ${{ github.event.inputs.distTag }}
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*/

0 comments on commit b3d3a61

Please sign in to comment.