|
1 |
| -name: Publish |
| 1 | +name: Verify and Publish |
2 | 2 |
|
3 | 3 | on:
|
| 4 | + push: |
4 | 5 | workflow_dispatch:
|
5 | 6 | inputs:
|
6 | 7 | segment:
|
|
10 | 11 | description: "Appended to the pre-release segment. (default: \"\")"
|
11 | 12 |
|
12 | 13 | jobs:
|
13 |
| - build: |
| 14 | + verify: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Setup Node.js environment |
| 22 | + uses: actions/setup-node@v3 |
| 23 | + with: |
| 24 | + node-version-file: ".nvmrc" |
| 25 | + |
| 26 | + - name: Install dependencies |
| 27 | + run: npm ci |
| 28 | + |
| 29 | + - name: Typecheck |
| 30 | + run: npm run typecheck |
| 31 | + - name: ESLint |
| 32 | + run: npm run eslint |
| 33 | + - name: Prettier |
| 34 | + run: npm run prettier |
| 35 | + - name: depcheck |
| 36 | + run: npm run depcheck |
| 37 | + |
| 38 | + - name: Test |
| 39 | + run: npm run buildtests && npm run test |
| 40 | + |
| 41 | + - name: Build |
| 42 | + run: npm run build |
| 43 | + |
| 44 | + publish: |
| 45 | + if: github.event_name == 'workflow_dispatch' |
| 46 | + needs: verify |
| 47 | + |
| 48 | + concurrency: |
| 49 | + group: "publish" |
| 50 | + cancel-in-progress: false |
| 51 | + |
14 | 52 | runs-on: ubuntu-latest
|
15 | 53 | permissions:
|
16 | 54 | contents: write
|
17 | 55 | packages: write
|
18 | 56 |
|
19 | 57 | steps:
|
20 | 58 | - name: Checkout
|
21 |
| - uses: actions/checkout@v2 |
| 59 | + uses: actions/checkout@v3 |
22 | 60 |
|
23 |
| - - name: Use Node.js |
24 |
| - uses: actions/setup-node@v2 |
| 61 | + - name: Setup Node.js environment |
| 62 | + uses: actions/setup-node@v3 |
25 | 63 | with:
|
26 |
| - node-version: "16" |
| 64 | + node-version-file: ".nvmrc" |
27 | 65 |
|
28 |
| - - name: "Install" |
| 66 | + - name: Install dependencies |
29 | 67 | run: npm ci
|
30 | 68 |
|
31 |
| - - name: "Build" |
32 |
| - run: npm run build |
33 |
| - |
34 |
| - - name: "Test" |
35 |
| - run: npm run buildtests && npm run test |
| 69 | + - name: Determine Tag |
| 70 | + id: tag |
| 71 | + run: | |
| 72 | + if [[ ${{ github.event.inputs.segment }} == pre* ]]; then |
| 73 | + echo "tag=next" >> $GITHUB_OUTPUT |
| 74 | + else |
| 75 | + echo "tag=latest" >> $GITHUB_OUTPUT |
| 76 | + fi |
36 | 77 |
|
37 | 78 | - name: Increment Version
|
38 | 79 | run: |
|
39 | 80 | git config --local user.email "Workflow: ${{ env.GITHUB_WORKFLOW }}[bot]"
|
40 | 81 | git config --local user.name "${{ env.GITHUB_WORKFLOW }}[bot]@workflow"
|
41 | 82 |
|
42 | 83 | if [[ ${{ github.event.inputs.segment }} == pre* ]]; then
|
43 |
| - PRE_ID="${{ github.event.inputs.preId}}" |
| 84 | + PRE_ID="${{ github.event.inputs.preId }}" |
44 | 85 | if [[ -n "$PRE_ID" ]]; then
|
45 | 86 | PRE_ID_COMMAND_STR="--preid $PRE_ID"
|
46 | 87 | fi
|
|
52 | 93 | uses: JS-DevTools/npm-publish@v1
|
53 | 94 | with:
|
54 | 95 | token: ${{ secrets.NPM_TOKEN }}
|
| 96 | + tag: ${{ steps.tag.outputs.tag }} |
55 | 97 |
|
56 | 98 | - name: Push Tag
|
57 | 99 | uses: ad-m/github-push-action@master
|
|
0 commit comments