forked from libbpf/libbpf-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (62 loc) · 2.31 KB
/
publish.yml
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
name: Publish
on:
workflow_dispatch:
jobs:
version:
name: Check workspace member versions
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: version
shell: bash
run: |
libbpf_rs_version="$(cd libbpf-rs && cargo pkgid | cut -d '#' -f2 | grep -o '[^:]*$')"
libbpf_cargo_version="$(cd libbpf-cargo && cargo pkgid | cut -d '#' -f2 | grep -o '[^:]*$')"
if [ -z "${libbpf_rs_version}" ]; then
echo "Invalid libbpf-rs version number"
exit 1
fi
if [ "${libbpf_rs_version}" != "${libbpf_cargo_version}" ]; then
echo "libbpf-rs and libbpf-cargo have differing version (${libbpf_rs_version} vs. ${libbpf_cargo_version}"
exit 1
fi
echo "version=${libbpf_rs_version}" >> $GITHUB_OUTPUT
test:
uses: ./.github/workflows/test.yml
publish:
needs: [test, version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Dry-run package creation
# Can't verify libbpf-cargo for it may depend on yet-to-be-published libbpf-rs.
run: cargo package --package libbpf-rs --locked --no-verify
- name: Create git tag
env:
version: ${{ needs.version.outputs.version }}
run: |
curl --location \
--request POST \
--url https://api.github.com/repos/${{ github.repository }}/releases \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
--header "X-GitHub-Api-Version: 2022-11-28" \
--data "{
\"tag_name\":\"v${version}\",
\"target_commitish\":\"${{ github.ref }}\",
\"name\":\"v${version}\",
\"draft\":false,
\"prerelease\":false,
\"generate_release_notes\":false
}"
- name: Publish libbpf-rs
run: cd libbpf-rs && cargo publish --locked --no-verify --token "${CRATES_IO_TOKEN}"
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish libbpf-cargo
run: cd libbpf-cargo && cargo publish --locked --no-verify --token "${CRATES_IO_TOKEN}"
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}