-
Notifications
You must be signed in to change notification settings - Fork 110
166 lines (153 loc) · 5.17 KB
/
Copy pathjavascript.yml
File metadata and controls
166 lines (153 loc) · 5.17 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Build and Test JavaScript
on:
workflow_run:
workflows: ["Flake maintenance"]
types: [requested]
branches:
- "update_flake_lock_action"
pull_request:
paths:
- payjoin-ffi/**
# The jobs run inside the flake's dev shell, so changes to the flake
# change this workflow's environment.
- flake.nix
- flake.lock
push:
tags:
- "payjoin-javascript-[0-9]*"
jobs:
build-js-and-test:
name: "Build and test javascript"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-26.04, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: "Use cache"
uses: Swatinem/rust-cache@v2
- name: Set up nix
uses: ./.github/actions/setup-nix
- name: "Build and test"
run: nix develop .#javascript -c ./payjoin-ffi/javascript/contrib/test.sh
pack-npm:
# The package ships only dist/ (wasm + compiled TypeScript), which is
# platform-independent, so one pack on Linux is the entire release build.
name: "Pack npm package"
runs-on: ubuntu-26.04
steps:
- name: Checkout
uses: actions/checkout@v6
- name: "Use cache"
uses: Swatinem/rust-cache@v2
- name: Set up nix
uses: ./.github/actions/setup-nix
- name: Build and pack
run: nix develop .#javascript -c ./payjoin-ffi/javascript/contrib/pack.sh
- name: Upload npm package
uses: actions/upload-artifact@v4
with:
name: payjoin-javascript-npm-package
path: payjoin-ffi/javascript/artifacts/*.tgz
if-no-files-found: error
smoke-npm:
name: "Smoke test npm package"
runs-on: ${{ matrix.os }}
needs: pack-npm
strategy:
matrix:
os: [ubuntu-26.04, macos-latest]
steps:
- name: Download npm package
uses: actions/download-artifact@v4
with:
name: payjoin-javascript-npm-package
path: pkg
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Install and exercise the packed package
shell: bash
run: |
set -euo pipefail
mkdir smoke && cd smoke
npm init -y >/dev/null
npm install ../pkg/payjoin-*.tgz
node --input-type=module -e '
import { payjoin, uniffiInitAsync } from "payjoin";
await uniffiInitAsync();
payjoin.Url.parse("https://example.com");
console.log("smoke ok");
'
verify-tag:
name: "Verify release tag"
if: startsWith(github.ref, 'refs/tags/payjoin-javascript-')
permissions:
contents: read
uses: ./.github/workflows/verify-tag-hygiene.yml
publish-npm:
name: "Publish to npmjs.com (trusted publishing / OIDC)"
runs-on: ubuntu-26.04
needs: [build-js-and-test, pack-npm, smoke-npm, verify-tag]
if: startsWith(github.ref, 'refs/tags/payjoin-javascript-')
environment: release
permissions:
id-token: write # OIDC: npm trusted publishing and its provenance statement
attestations: write # actions/attest writes the attestation
contents: read # needed only to check out the in-repo verify-tag-version action
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download npm package
uses: actions/download-artifact@v4
with:
name: payjoin-javascript-npm-package
path: dist
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: https://registry.npmjs.org
- name: Update npm
run: |
npm install -g npm@11
npm --version
- name: Locate packed artifact
id: locate
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
pkgs=(dist/payjoin-*.tgz)
if [ "${#pkgs[@]}" -ne 1 ]; then
echo "::error::expected exactly one .tgz in dist/, found ${#pkgs[@]}: ${pkgs[*]:-none}"
exit 1
fi
# payjoin-0.1.1.tgz -> 0.1.1
name="$(basename "${pkgs[0]}" .tgz)"
echo "tarball=${pkgs[0]}" >> "$GITHUB_OUTPUT"
echo "version=${name#payjoin-}" >> "$GITHUB_OUTPUT"
- name: Verify tag matches packed artifact version
uses: ./.github/actions/verify-tag-version
with:
tag-prefix: payjoin-javascript-
version: ${{ steps.locate.outputs.version }}
- name: Attest build provenance (tarball)
# A consumer runs: gh attestation verify <file>.tgz -R payjoin/rust-payjoin
uses: actions/attest@v4
with:
subject-path: ${{ steps.locate.outputs.tarball }}
- name: Publish to npmjs.com
run: npm publish "${{ steps.locate.outputs.tarball }}"
github-release:
name: "Attach tarball + SHA256SUMS to the GitHub release"
needs: [publish-npm]
if: startsWith(github.ref, 'refs/tags/payjoin-javascript-')
permissions:
contents: write # create/update the Release for this tag and upload assets
uses: ./.github/workflows/release-assets.yml
with:
artifact-pattern: payjoin-javascript-npm-package
tag-prefix: payjoin-javascript-