-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add release workflow for shipping binaries and combined sources (veristat+libbpf) #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks a lot for contributing this! I have a small nit about naming of full sources archive, can you please address and update the PR?
I think .zip isn't that important, .tar.gz should be plenty (especially that veristat works only on Linux anyways).
Create a GitHub workflow that runs when new tags are created, in order to create a draft release containing a new asset: an archive with all sources required to build veristat, in other words, the sources of veristat and of its libbpf submodule. The draft release is at https://github.com/libbpf/veristat/releases, and needs to be published manually. Note that the release author will be "github-actions" instead of the person who manually publishes from the draft. The motivation for adding an archive with the sources of both veristat and libbpf is to help with packaging: there is only one archive to handle to get all the sources, without having to care about git submodules. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Now that we have a release workflow, we can also use it to ship (statically-built) binaries. This commit builds veristat both for amd64 (the arch of the GitHub runner) and arm64 (using QEMU to cross-compile). Signed-off-by: Quentin Monnet <quentin@isovalent.com>
5ef0836
to
176eea0
Compare
The nits should be addressed. Thanks for the review! diffdiff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3c13df120fa0..d2fa00fa9fbd 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -109,7 +109,7 @@ jobs:
- name: Package source code including submodules
run: |
tar -I 'gzip -9' --exclude-vcs \
- -cvf "veristat-libbpf-${{ github.ref_name }}-sources.tar.gz" veristat
+ -cvf "veristat-all-sources-${{ github.ref_name }}.tar.gz" veristat
- name: Create draft release and add artifacts
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
diff --git a/scripts/gh-label-release-assets.sh b/scripts/gh-label-release-assets.sh
index 51f9ba5bfa08..ad6ac9bf6a39 100755
--- a/scripts/gh-label-release-assets.sh
+++ b/scripts/gh-label-release-assets.sh
@@ -59,7 +59,7 @@ echo "repo: ${REPO}, release tag: ${release_tag}"
# Add labels to set for given asset names here:
declare -A assets_labels=(
- ["veristat-libbpf-${release_tag}-sources.tar.gz"]="Source code, including libbpf submodule (tar.gz)"
+ ["veristat-libbpf-${release_tag}-sources.tar.gz"]="Full source code with submodules (tar.gz)"
)
# Get release ID
@@ -78,6 +78,8 @@ for asset_name in "${!assets_labels[@]}"; do
case "${answer}" in
y|yes|Y|Yes|YES)
+ # Note: A 404 error at this stage may be synonymous with
+ # insufficient permissions for the token in use for gh.
gh api \
--method PATCH \
-H 'Accept: application/vnd.github+json' \ |
The only way I've found to add a label to existing release assets on GitHub is via the GitHub API. Add a script to "rename" (add a label) to existing assets. In particular, we rename the archive containing the sources for veristat and its libbpf submodule. Example invocation (with REPO modified to point to my fork): $ ./scripts/gh-label-release-assets.sh test02 repo: qmonnet/veristat, release tag: test02 found release ID 101340990 found asset ID 105863030 asset 'veristat-all-sources-test02.tar.gz': add label 'Full source code with submodules (tar.gz)' proceed? [y/N]: y [ ... JSON output from server reply to API request ... ] After running the script, instead of being listed as "veristat-all-sources-<tag>.tar.gz", the asset appears on GitHub's interface as "Full source code with submodules (tar.gz)". More assets could easily be renamed as well by extending the array in the script. The script is not run from CI, because it requires the release to be published (we only automated the creation of the draft release). The script requires the GitHub command line ("gh") to be set up. If the asset is found but the update fails with a 404 error, this is usually synonymous with insufficient permissions for the GitHub token in use. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
176eea0
to
5ca2a80
Compare
Fixed, I did another test release and ran the script on top of it to validate that all is in order. |
This is awesome, thanks a lot, @qmonnet! |
Add a new GitHub workflow that runs when new tags are pushed. This workflow creates a draft release based on the tag, that a user can then publish. It adds assets to this draft release: a tarball containing the combined sources of veristat and its libbpf submodule, for ease of packaging (first commit), and binaries for amd64 and arm64, built statically (second commit). The third commit is a script to rename some assets on the release page.
I can discard some of the commits if you're not interested, obviously.
Note that the release author on the GitHub interface will appear as
github-actions
, and not as the person who finalises and publishes the release. This probably does not matter at all.Some items that are not part of the PR:
'v[0-9]+.[0-9]+'
instead of'**'
scripts/archive-srcs-full.sh
This derives from the release workflow in use for bpftool, developed in collaboration with Mahé Tardy.