Repository navigation
97 lines (92 loc) · 3.3 KB
/
Copy pathpush.yaml
File metadata and controls
97 lines (92 loc) · 3.3 KB
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
94
95
96
97
name: Build and Test
on:
push:
branches:
- master
pull_request:
permissions:
contents: read
jobs:
test:
name: Build & Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
- run: npm run lint:ci
- run: npm run typecheck
- run: npm run build
- run: npm audit --audit-level=high
- run: npm run test:coverage
- run: npm run test:consumer
- name: Pack the qualified publication artifact
if: matrix.node-version == 24
run: |
npm pack --ignore-scripts --json > publication.json
sha256sum bsv-identity-react-*.tgz > publication.sha256
- name: Retain the exact qualified package
if: matrix.node-version == 24
uses: actions/upload-artifact@v4
with:
name: identity-react-npm-${{ github.sha }}
path: |
bsv-identity-react-*.tgz
publication.json
publication.sha256
if-no-files-found: error
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
publish:
name: Publish
needs: test
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
- uses: actions/download-artifact@v4
with:
name: identity-react-npm-${{ github.sha }}
path: release
- name: Verify the immutable publication artifact
working-directory: release
run: sha256sum --check publication.sha256
- name: Check if version already published
id: check-version
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Package: $PACKAGE_NAME@$PACKAGE_VERSION"
# Existing immutable versions must be the same qualified bytes.
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" dist.integrity --json > registry-integrity.json 2>/dev/null; then
node -e 'const assert = require("node:assert/strict"); assert.equal(require("./registry-integrity.json"), require("./release/publication.json")[0].integrity, "Published version differs from the qualified artifact")'
echo "Version $PACKAGE_VERSION already published with matching integrity"
echo "should_publish=false" >> $GITHUB_OUTPUT
else
echo "Version $PACKAGE_VERSION not yet published"
echo "should_publish=true" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
if: steps.check-version.outputs.should_publish == 'true'
run: npm publish "./release/$(node -p 'require("./release/publication.json")[0].filename')" --ignore-scripts --provenance
- name: Skip publishing
if: steps.check-version.outputs.should_publish == 'false'
run: echo "Skipping publish - version already exists on npm"