|
11 | 11 | types: [created] |
12 | 12 |
|
13 | 13 | jobs: |
14 | | - build-and-test: |
15 | | - name: Build and Test |
| 14 | + build-test-publish: |
| 15 | + name: Build, Test & Publish |
16 | 16 | runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + id-token: write |
17 | 20 |
|
18 | 21 | steps: |
19 | 22 | - name: Checkout code |
|
29 | 32 | experimental-features = nix-command flakes |
30 | 33 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |
31 | 34 |
|
| 35 | + - name: Setup Node.js (for publishing) |
| 36 | + if: (github.event_name == 'release' && github.event.action == 'created') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: "20" |
| 40 | + registry-url: "https://registry.npmjs.org" |
| 41 | + |
32 | 42 | - name: Cache Emscripten |
33 | 43 | uses: actions/cache@v3 |
34 | 44 | with: |
@@ -94,64 +104,9 @@ jobs: |
94 | 104 | test/*.log |
95 | 105 | if-no-files-found: ignore |
96 | 106 |
|
97 | | - publish: |
98 | | - name: Publish |
99 | | - needs: build-and-test |
100 | | - runs-on: ubuntu-latest |
101 | | - if: (github.event_name == 'release' && github.event.action == 'created') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
102 | | - permissions: |
103 | | - contents: write |
104 | | - id-token: write |
105 | | - |
106 | | - steps: |
107 | | - - name: Checkout code |
108 | | - uses: actions/checkout@v4 |
109 | | - with: |
110 | | - submodules: recursive |
111 | | - |
112 | | - - name: Install Nix |
113 | | - uses: cachix/install-nix-action@v24 |
114 | | - with: |
115 | | - nix_path: nixpkgs=channel:nixos-unstable |
116 | | - extra_nix_config: | |
117 | | - experimental-features = nix-command flakes |
118 | | -
|
119 | | - - name: Setup Node.js |
120 | | - uses: actions/setup-node@v4 |
121 | | - with: |
122 | | - node-version: "20" |
123 | | - registry-url: "https://registry.npmjs.org" |
124 | | - |
125 | | - - name: Cache Emscripten |
126 | | - uses: actions/cache@v3 |
127 | | - with: |
128 | | - path: .emscripten-cache |
129 | | - key: ${{ runner.os }}-emscripten-${{ hashFiles('flake.lock') }} |
130 | | - restore-keys: | |
131 | | - ${{ runner.os }}-emscripten- |
132 | | -
|
133 | | - - name: Cache OpenSSL |
134 | | - uses: actions/cache@v3 |
135 | | - with: |
136 | | - path: openssl-wasm |
137 | | - key: ${{ runner.os }}-openssl-3.3.2-wasm |
138 | | - restore-keys: | |
139 | | - ${{ runner.os }}-openssl- |
140 | | -
|
141 | | - - name: Build OpenSSL |
142 | | - run: | |
143 | | - if [ ! -d "openssl-wasm/lib" ]; then |
144 | | - echo "Building OpenSSL for WASM..." |
145 | | - nix develop --command bash -c "./build-openssl.sh" |
146 | | - else |
147 | | - echo "Using cached OpenSSL" |
148 | | - fi |
149 | | -
|
150 | | - - name: Build WASM for release |
151 | | - run: | |
152 | | - nix develop --command bash -c "./build.sh" |
153 | | -
|
| 107 | + # Publishing steps (only run on tags) |
154 | 108 | - name: Verify package contents |
| 109 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
155 | 110 | run: | |
156 | 111 | npm pack --dry-run |
157 | 112 | ls -lh dist/ |
|
0 commit comments