mirror of
https://github.com/alexgo-io/stacks.js.git
synced 2026-01-12 17:52:41 +08:00
68 lines
2.3 KiB
YAML
68 lines
2.3 KiB
YAML
name: pull-request
|
|
on:
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
pre-run:
|
|
uses: ./.github/workflows/pre-run.yml
|
|
secrets: inherit
|
|
|
|
commitlint:
|
|
runs-on: ubuntu-latest
|
|
needs: pre-run
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: wagoid/commitlint-github-action@v5
|
|
|
|
tests:
|
|
needs: pre-run
|
|
uses: ./.github/workflows/tests.yml
|
|
|
|
publish-pr:
|
|
runs-on: ubuntu-latest
|
|
needs: [pre-run, tests]
|
|
if: needs.pre-run.outputs.is-not-fork == 'true'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
if: github.event_name == 'pull_request'
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
- uses: actions/checkout@v3
|
|
if: github.event_name == 'workflow_dispatch'
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
cache: npm
|
|
- run: npm install -g npm@latest
|
|
- run: npm ci
|
|
- id: git-commit
|
|
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
|
|
- run: echo $SHA
|
|
env:
|
|
SHA: ${{ steps.git-commit.outputs.sha }}
|
|
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
- run: npx lerna publish prepatch --preid pr.$SHA --dist-tag pr --no-verify-access --no-push --no-git-tag-version --yes
|
|
env:
|
|
SHA: ${{ steps.git-commit.outputs.sha }}
|
|
SKIP_TESTS: true
|
|
- id: published-version
|
|
run: echo "::set-output name=version::$(cat lerna.json | jq -r '.version')"
|
|
- uses: janniks/pull-request-fixed-header@v1.0.1
|
|
with:
|
|
header: "> This PR was published to npm with the version `${{ steps.published-version.outputs.version }}`\n> e.g. `npm install @stacks/common@${{ steps.published-version.outputs.version }} --save-exact`"
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- run: |
|
|
git reset --hard
|
|
npx lerna publish --canary --preid $BRANCH.$SHA --dist-tag $BRANCH --no-verify-access --no-push --no-git-tag-version --yes
|
|
if: ${{ (github.head_ref || github.ref_name) == 'nakamoto' || (github.head_ref || github.ref_name) == 'next' }}
|
|
env:
|
|
BRANCH: ${{ github.head_ref || github.ref_name }}
|