-
Notifications
You must be signed in to change notification settings - Fork 41
93 lines (89 loc) · 3.37 KB
/
pull_request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Pull Request
on: [pull_request, workflow_dispatch]
jobs:
check_fork:
name: Disable jobs for forks
runs-on: ubuntu-latest
outputs:
is_not_fork: ${{ steps.is_not_fork.outputs.is_not_fork }}
steps:
- name: Check for secret
id: is_not_fork
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "Is a fork: ${{ env.NPM_TOKEN == '' }}"
echo "::set-output name=is_not_fork::${{ env.NPM_TOKEN != '' }}"
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
code_checks:
name: Code checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Code Checks
uses: ./.github/actions/code-checks
publish_npm_betas:
name: Publish NPM beta versions
runs-on: ubuntu-latest
needs: [check_fork]
if: needs.check_fork.outputs.is_not_fork == 'true'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install monorepo deps
run: npm ci
- name: Setup .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- name: Get git branch
id: git-branch
run: echo "::set-output name=branch::$(git rev-parse --abbrev-ref HEAD | cut -d'/' -f2 )"
- name: Get git commit
id: git-commit
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: print preid
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: echo $BRANCH.$SHA
- name: Setup git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Publish to NPM
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: npx lerna publish prepatch --preid alpha.$SHA --dist-tag $BRANCH --yes --no-push
- name: Get alpha package versions
id: alpha
run: |
echo "connect=$(cat packages/connect/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
echo "connectreact=$(cat packages/connect-react/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
echo "connectui=$(cat packages/connect-ui/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
- uses: janniks/[email protected]
with:
header: "> This PR was published to npm with the alpha versions:\n> - connect `npm install @stacks/connect@${{ steps.alpha.outputs.connect }} --save-exact`\n> - connect-react `npm install @stacks/connect-react@${{ steps.alpha.outputs.connectreact }} --save-exact`\n> - connect-ui `npm install @stacks/connect-ui@${{ steps.alpha.outputs.connectui }} --save-exact`"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}