88env :
99 CARGO_TERM_COLOR : always
1010
11+ permissions :
12+ contents : read
13+ packages : write
14+
1115jobs :
1216 detect-changes :
1317 runs-on : ubuntu-latest
1721 - uses : actions/checkout@v4
1822 with :
1923 fetch-depth : 0
20-
21- - name : Get changed files
22- id : changed-files
23- uses : tj-actions/changed-files@v41
24-
25- - name : Discover changed crates
26- id : set-matrix
27- run : |
28- # Get all workspace members
29- crates=$(cargo metadata --format-version=1 | jq -r '.workspace_members[]' | cut -d'#' -f1 | rev | cut -d'/' -f1 | rev)
30-
31- changed_crates=()
32- for crate in $crates; do
33- # Get crate path from metadata
34- crate_path=$(cargo metadata --format-version=1 | jq -r ".packages[] | select(.name == \"$crate\") | .manifest_path" | xargs dirname)
35-
36- # Check if any files in this crate changed
37- if echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -q "$crate_path"; then
38- changed_crates+=("$crate")
39- fi
40- done
41-
42- # Convert to JSON matrix
43- if [ ${#changed_crates[@]} -eq 0 ]; then
44- echo "matrix={\"component\":[]}" >> $GITHUB_OUTPUT
45- else
46- matrix=$(printf '%s\n' "${changed_crates[@]}" | jq -R . | jq -s .)
47- echo "matrix={\"component\":$matrix}" >> $GITHUB_OUTPUT
48- fi
24+ - run : chmod +x .github/scripts/detect-changes.sh
25+ - id : set-matrix
26+ run : .github/scripts/detect-changes.sh
4927
5028 build-and-publish :
5129 needs : detect-changes
@@ -55,13 +33,25 @@ jobs:
5533 matrix :
5634 component : ${{ fromJson(needs.detect-changes.outputs.matrix).component }}
5735 steps :
36+ # Setup
5837 - uses : actions/checkout@v4
5938 - uses : dtolnay/rust-toolchain@nightly
6039 - uses : Swatinem/rust-cache@v2
61- - run : cargo install --locked wkg
40+ - uses : cargo-bins/cargo-binstall@main
41+ - run : cargo binstall --locked --force cargo-component
42+ - run : cargo binstall --locked --force wkg
6243
6344 # Build
64- - run : cargo component build -p {{ component}} --release
45+ - run : cargo component build -p ${{ matrix. component }} --release
6546
6647 # Publish
67- - run : wkg oci push ghcr.io/wassemble/{{component}}:latest target/wasm32-wasip1/release/$(echo {{component}} | tr '-' '_').wasm
48+ - run : wkg oci push ghcr.io/wassemble/${{ matrix.component }}:latest target/wasm32-wasip1/release/$(echo ${{ matrix.component }} | tr '-' '_').wasm --annotation org.opencontainers.image.title=${{ matrix.component }} --annotation org.opencontainers.image.description="WASM Component" --annotation org.opencontainers.image.type=wasm -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
49+
50+ # Make package public
51+ - run : |
52+ echo "Making package public..."
53+ curl -X PATCH \
54+ -H "Accept: application/vnd.github.v3+json" \
55+ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
56+ https://api.github.com/user/packages/container/${{ matrix.component }}/visibility \
57+ -d '{"visibility":"public"}'
0 commit comments