Repository navigation
129 lines (125 loc) · 4.71 KB
/
Copy pathci.yaml
File metadata and controls
129 lines (125 loc) · 4.71 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
name: CI
on:
push:
branches:
- "**"
- "!dependabot/**"
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+-?**'
pull_request: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main
- name: Install tools
# the versions pinned in tools/Cargo.toml, on the path for later steps
run: |
make tools
make -s tools-path >> "${GITHUB_PATH}"
- name: Sync wit
run: make wit
- name: Check for drift in generated wit
run: git diff --exit-code .
- name: Build components
run: make components
- name: Collect components.tar
run: tar -cvf ../../components.tar .
working-directory: ./target/components
- name: Upload components.tar
uses: actions/upload-artifact@v7
with:
name: components.tar
path: components.tar
retention-days: 7
- name: Test
run: make test
- name: Capture WIT
working-directory: ./target/components
run: |
dump_wit() {
echo "::group::$(basename "$1") ($(du -h "$1" | awk '{print $1}' ))"
wasm-tools component wit "$1"
echo "::endgroup::"
}
# print interface.wasm first
if [ -f interface.wasm ] ; then
dump_wit interface.wasm
fi
for component in $(find . -name '*.wasm' -not -name '*.debug.wasm' -not -name 'interface.wasm' | sort) ; do
dump_wit "${component}"
done
publish:
if: github.event_name == 'push' && ( startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' )
needs:
- build
permissions:
contents: write
packages: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
- name: Install cargo binstall
uses: cargo-bins/cargo-binstall@main
- name: Install tools
run: |
make tools
make -s tools-path >> "${GITHUB_PATH}"
- name: Install cosign
uses: sigstore/cosign-installer@v4.1.2
- name: Download components.tar
uses: actions/download-artifact@v8
with:
name: components.tar
- name: Extract components
run: mkdir -p target/components && tar -xvf components.tar -C target/components
- name: Get interface version
id: interface_version
run: echo "VERSION=$( wasm-tools component wit target/components/interface.wasm --json | jq -r "[.packages[] | select(.name | contains(\"${GITHUB_REPOSITORY/\//:}@\"))][0].name" | cut -d'@' -f2 )" >> $GITHUB_OUTPUT
- name: Get tag version
if: startsWith(github.ref, 'refs/tags/')
id: tag_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish components to gchr.io
# only publish tags and pre-releases from main
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && contains(steps.interface_version.outputs.VERSION, '-'))
run: make publish
env:
PUBLISH_LOG: "${{ runner.temp }}/published.txt"
REPOSITORY: "ghcr.io/${{ github.repository }}"
VERSION: "${{ case(github.ref == 'refs/heads/main', steps.interface_version.outputs.VERSION, steps.tag_version.outputs.VERSION) }}"
- name: Draft release notes
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && contains(steps.interface_version.outputs.VERSION, '-'))
run: |
{
echo "## Published components"
echo
echo "| File | Size | Image |"
echo "| --- | --: | --- |"
while read -r file bytes image ; do
size=$( numfmt --to=iec-i --suffix=B --format=%.1f "${bytes}" )
echo "| \`${file}\` | ${size} | \`${image}\` |"
done < "${RUNNER_TEMP}/published.txt"
} > "${RUNNER_TEMP}/release-notes.md"
cat "${RUNNER_TEMP}/release-notes.md"
- name: Draft GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
draft: true
body_path: ${{ runner.temp }}/release-notes.md
files: |
components.tar
fail_on_unmatched_files: true
token: ${{ secrets.GITHUB_TOKEN }}