-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (64 loc) · 1.76 KB
/
cd.yml
File metadata and controls
72 lines (64 loc) · 1.76 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
name: CD
on:
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
packages: write
id-token: write
actions: read
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: chmod +x .github/scripts/detect-changes.sh
- id: set-matrix
run: .github/scripts/detect-changes.sh
publish:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.matrix != '[]' }}
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
strategy:
matrix:
component: ${{ fromJson(needs.detect-changes.outputs.matrix).component }}
steps:
# Setup
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-component
- uses: taiki-e/cache-cargo-install-action@v2
with:
tool: wit-bindgen-cli
# Configure registry
- run: |
cat > config.toml << EOF
default_registry = "ghcr.io"
[registry."ghcr.io".oci.auth]
password = "${{ secrets.GH_TOKEN }}"
username = "wassemble"
EOF
# Publish
- run: |
cargo component publish -p ${{ matrix.component }} --config config.toml
# NPM package
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: .github/scripts/publish-npm.sh ${{ matrix.component }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}