Skip to content

Commit ed3a018

Browse files
authored
Merge pull request #1 from vmcruz/chore/workflow-updates
Chore: Workflow updates
2 parents b1f213c + 623416c commit ed3a018

File tree

3 files changed

+113
-17
lines changed

3 files changed

+113
-17
lines changed

.github/workflows/ci.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
run-name: CI run for ${{ github.head_ref }}
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
paths-ignore:
9+
- '**/*.md'
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version-file: 'package.json'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run linting
28+
run: npm run lint
29+
30+
tsc:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version-file: 'package.json'
40+
cache: 'npm'
41+
42+
- name: Install dependencies
43+
run: npm ci
44+
45+
- name: Check TypeScript syntax
46+
run: npx tsc --noEmit
47+
48+
test:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
54+
- name: Set up Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version-file: 'package.json'
58+
cache: 'npm'
59+
60+
- name: Install dependencies
61+
run: npm ci
62+
63+
- name: Run tests
64+
run: npm test

.github/workflows/publish.yaml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: Publish to npm
2-
run-name: ${{ github.ref_name }} ${{ inputs.dry_run == true && ' (dry-run)' || '' }}
2+
run-name: ${{ github.ref_name }}
33

44
on:
55
workflow_dispatch:
66
inputs:
7-
dry_run:
8-
type: boolean
9-
description: Run as a dry-run (no publish)
10-
default: true
7+
environment:
8+
type: environment
9+
description: Environment
10+
required: true
1111

1212
permissions:
13-
id-token: write # Required for --provenancepermissions:
13+
id-token: write # Required for --provenance
1414
contents: read
1515
packages: write
1616

@@ -19,12 +19,6 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- run: |
23-
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
24-
echo "This workflow can only be run from a tag."
25-
exit 1
26-
fi
27-
2822
- name: Checkout repository
2923
uses: actions/checkout@v4
3024

@@ -44,12 +38,7 @@ jobs:
4438
id: dist_tag
4539
run: echo "value=$(cat package.json | jq -r '.version | split("-") | .[1] // "latest" | split(".") | .[0]')" >> $GITHUB_OUTPUT
4640

47-
- name: Dry run publish (${{ steps.dist_tag.outputs.value }})
48-
run: npm publish --dry-run --provenance --tag ${{ steps.dist_tag.outputs.value }} --access=public
49-
if: inputs.dry_run == true
50-
5141
- name: Publish to npm
5242
run: npm publish --provenance --tag ${{ steps.dist_tag.outputs.value }} --access=public
53-
if: inputs.dry_run == false
5443
env:
5544
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish to npm dry-run
2+
run-name: Dry-run ${{ github.ref_name }}
3+
4+
on:
5+
workflow_dispatch:
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- run: |
18+
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
19+
echo "This workflow can only be run from a tag."
20+
exit 1
21+
fi
22+
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version-file: 'package.json'
30+
registry-url: 'https://registry.npmjs.org'
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build package
36+
run: npm run build
37+
38+
- name: Extract dist tag from version
39+
id: dist_tag
40+
run: echo "value=$(cat package.json | jq -r '.version | split("-") | .[1] // "latest" | split(".") | .[0]')" >> $GITHUB_OUTPUT
41+
42+
- name: Dry run publish (${{ steps.dist_tag.outputs.value }})
43+
run: npm publish --dry-run --provenance --tag ${{ steps.dist_tag.outputs.value }} --access=public

0 commit comments

Comments
 (0)