-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Flow-IPC/polish
upload-release-asset action refuses to work ("Invalid name for request") no matter what experimental simplification I use, so instead using curl to explicitly make the upload POST. It worked experimentally, so now doing it for real. The code is actually shorter.
- Loading branch information
Showing
1 changed file
with
34 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1076,7 +1076,7 @@ jobs: | |
git config user.email [email protected] | ||
# We are forced to use a Personal Access Token attached to a special bot user such that in repo Settings | ||
# we've configured that "guy" as allowed to bypass the requirement to merge via PR. As of this writing | ||
# there's no way to configure the default token to being able to do this. | ||
# there's no way to configure the default token to be able to do this. | ||
# TODO: Keep an eye on that in case they provide for a better way: | ||
# https://github.com/orgs/community/discussions/25305 | ||
git config --local http.https://github.com/.extraheader \ | ||
|
@@ -1103,21 +1103,40 @@ jobs: | |
# We want a source tarball and/or zip to be attached to the Release. Delightfully, GitHub does this | ||
# automatically. Less delightfully, we have submodules -- where most of the code is in fact -- which GitHub | ||
# will not include (they'll just be empty dirs instead). So we upload those manually. | ||
- name: (On release creation only) Prepare full source package(s) to attach to Release page | ||
id: prep_release_pkgs | ||
# | ||
# Regarding the actual upload request (x2): We do it via curl, following the documented GitHub API. | ||
# Some resources recommend doing this (x2) instead: | ||
# uses: actions/[email protected] | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# upload_url: ${{ steps.prep_release_pkgs.outputs.upload-url }} | ||
# asset_path: ${{ github.workspace }}/../${{ steps.prep_release_pkgs.outputs.tgz-name }} | ||
# asset_name: ${{ steps.prep_release_pkgs.outputs.tgz-name }} | ||
# asset_content_type: application/gzip | ||
# For me (ygoldfel), despite a few hours of trying this and that and attempting to get debug output, it kept | ||
# yielding `Invalid name for request` error with no added info. Reasons might be: some silly error on my part | ||
# (but it is very vanilla, and I reduced it down to the bare essentials with no success, while also eliminating | ||
# possibilities like it being unable to find the local file to upload and other stupidities); a change in API | ||
# or some other behavior that was not handled by the upload-release-asset action package; possibly a break | ||
# in a dependency of upload-release-asset (octokat?). upload-release-asset was last updated in 2020 and is | ||
# officially now unmaintained. So I fought valiantly but eventually moved onto just using curl which worked | ||
# almost immediately. Since the resulting code isn't even longer, and we are using a documented public API and | ||
# standard tool (curl) which we also use elsewhere, it seemed a reasonable approach. TODO: Revisit perhaps. | ||
- name: (On release creation only) Attach full source package(s) to Release | ||
if: success() && (!cancelled()) && startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
# Prepare full source package(s) to attach to Release page. | ||
# Attach full source package(s) to Release | ||
cd ${{ github.workspace }}/.. | ||
REPO=ipc | ||
VERSION=`echo ${{ github.ref }} | cut -c 12-` # E.g., refs/tags/v1.2.3-rc1 => 1.2.3-rc1. | ||
TGZ_NAME=$REPO-${VERSION}_full.tar.gz | ||
ZIP_NAME=$REPO-${VERSION}_full.zip | ||
# When making archives: get rid of or exclude (I do not want to `rm` .git... feels dangerous | ||
# against GitHub Actions): | ||
# When making archives: get rid of or exclude (I do not want to `rm -rf` .git... feels dangerous-ish, as | ||
# GitHub Actions cleans up checkouts later... just don't do it) the following: | ||
# - .git directories and files. (.gitignore and .gitmodules, among others, must stay.) | ||
# (tar --exclude-vcs sounds delightful, but it'll exclude .gitignore and .gitmodules at least.) | ||
# - Any tarball created earlier upon doc generation. | ||
# - Any doc tarball created earlier upon doc generation. | ||
rm -f $REPO/doc/$REPO_doc.tgz | ||
tar cvzf $TGZ_NAME --exclude=.git $REPO | ||
zip -r $ZIP_NAME $REPO --exclude '*/.git/*' '*/.git' | ||
|
@@ -1130,32 +1149,14 @@ jobs: | |
echo "For release [v$VERSION]: release-data API request yielded: [$RELEASE_DATA]." | ||
UPLOAD_URL=`echo $RELEASE_DATA | jq -r .upload_url | sed 's/{.*}$//'` | ||
echo "For release [v$VERSION]: upload-URL was computed to be: [$UPLOAD_URL]." | ||
echo "upload-url=$UPLOAD_URL" >> $GITHUB_OUTPUT | ||
echo "tgz-name=$TGZ_NAME" >> $GITHUB_OUTPUT | ||
echo "zip-name=$ZIP_NAME" >> $GITHUB_OUTPUT | ||
echo 'description=Source code (full)' >> $GITHUB_OUTPUT | ||
- name: (On release creation only) Attach full source package (tarball) to Release page | ||
if: (!cancelled()) && (steps.prep_release_pkgs.outcome == 'success') | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.prep_release_pkgs.outputs.upload-url }} | ||
asset_path: ${{ github.workspace }}/../${{ steps.prep_release_pkgs.outputs.tgz-name }} | ||
asset_name: ${{ steps.prep_release_pkgs.outputs.description }} | ||
asset_content_type: application/gzip | ||
|
||
- name: (On release creation only) Attach full source package (zip) to Release page | ||
if: (!cancelled()) && (steps.prep_release_pkgs.outcome == 'success') | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.prep_release_pkgs.outputs.upload-url }} | ||
asset_path: ${{ github.workspace }}/../${{ steps.prep_release_pkgs.outputs.zip-name }} | ||
asset_name: ${{ steps.prep_release_pkgs.outputs.description }} | ||
asset_content_type: application/zip | ||
curl --fail-with-body -X POST \ | ||
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ | ||
-H 'Content-Type: application/gzip' -H "Content-Length: $(wc -c < $TGZ_NAME)" \ | ||
--data-binary @$TGZ_NAME "$UPLOAD_URL?name=$TGZ_NAME" | ||
curl --fail-with-body -X POST \ | ||
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ | ||
-H 'Content-Type: application/zip' -H "Content-Length: $(wc -c < $ZIP_NAME)" \ | ||
--data-binary @$ZIP_NAME "$UPLOAD_URL?name=$ZIP_NAME" | ||
- name: (On release creation only) Signal Pages about release (web site should update) | ||
if: success() && (!cancelled()) && startsWith(github.ref, 'refs/tags/v') | ||
|