Skip to content

Commit 30363a1

Browse files
d-e-s-odanielocfb
authored andcommitted
Enhance publish workflow
A while back we added the publish workflow for publishing new releases of the workspace's crates to crates.io. This change enhances this workflow with the following logic: 1) we check that both the libbpf-rs and libbpf-cargo version are the same; we have decided to bump both in unison as that simplifies our lives 2) once we successfully published new versions of said crates, we create a git tag along with a GitHub release Signed-off-by: Daniel Müller <[email protected]>
1 parent 3a3c1be commit 30363a1

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,31 @@ on:
44
workflow_dispatch:
55

66
jobs:
7+
version:
8+
name: Check workspace member versions
9+
runs-on: ubuntu-latest
10+
outputs:
11+
version: ${{ steps.version.outputs.version }}
12+
steps:
13+
- uses: actions/checkout@v3
14+
- id: version
15+
shell: bash
16+
run: |
17+
libbpf_rs_version="$(cd libbpf-rs && cargo pkgid | cut -d '#' -f2 | grep -o '[^:]*$')"
18+
libbpf_cargo_version="$(cd libbpf-cargo && cargo pkgid | cut -d '#' -f2 | grep -o '[^:]*$')"
19+
if [ -z "${libbpf_rs_version}" ]; then
20+
echo "Invalid libbpf-rs version number"
21+
exit 1
22+
fi
23+
if [ "${libbpf_rs_version}" != "${libbpf_cargo_version}" ]; then
24+
echo "libbpf-rs and libbpf-cargo have differing version (${libbpf_rs_version} vs. ${libbpf_cargo_version}"
25+
exit 1
26+
fi
27+
echo "version=${libbpf_rs_version}" >> $GITHUB_OUTPUT
728
test:
829
uses: ./.github/workflows/test.yml
930
publish:
10-
needs: [test]
31+
needs: [test, version]
1132
runs-on: ubuntu-latest
1233
steps:
1334
- uses: actions/checkout@v3
@@ -17,6 +38,24 @@ jobs:
1738
profile: minimal
1839
toolchain: stable
1940
override: true
41+
- name: Create git tag
42+
env:
43+
version: ${{ needs.version.outputs.version }}
44+
run: |
45+
curl --location \
46+
--request POST \
47+
--url https://api.github.com/repos/${{ github.repository }}/releases \
48+
--header "Accept: application/vnd.github+json" \
49+
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
50+
--header "X-GitHub-Api-Version: 2022-11-28" \
51+
--data "{
52+
\"tag_name\":\"v${version}\",
53+
\"target_commitish\":\"${{ github.ref }}\",
54+
\"name\":\"v${version}\",
55+
\"draft\":false,
56+
\"prerelease\":false,
57+
\"generate_release_notes\":false
58+
}"
2059
- name: Publish libbpf-rs
2160
run: cd libbpf-rs && cargo publish --locked --no-verify --token "${CRATES_IO_TOKEN}"
2261
env:

0 commit comments

Comments
 (0)