Skip to content

Commit

Permalink
Add upload task
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed May 1, 2024
1 parent 2ae430a commit e2775de
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@ build_xournalpp_task:
(cd mac-setup && bash build-app.sh ~/gtk && bash build-dmg.sh Xournal++.app Xournal++.dmg)
xournalpp_artifacts:
path: mac-setup/Xournal++.dmg

github_upload_task:
depends_on:
- build_xournalpp
env:
GITHUB_TOKEN: ENCRYPTED[!a7eb9968bbfc1f1d79496117893528174c24e70046095d5f9096ecfe3bc19a8cadd675c0d91afb3e2d9707de131abdaf!]

xournalpp_upload_script: |
bash mac-setup/upload-release.sh
only_if: $BRANCH =~ 'release-.*'
27 changes: 27 additions & 0 deletions mac-setup/upload-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# See https://cirrus-ci.org/examples/#release-assets

if [[ "$CIRRUS_RELEASE" == "" ]]; then
echo "Not a release. No need to deploy!"
exit 0
fi

if [[ "$GITHUB_TOKEN" == "" ]]; then
echo "Please provide GitHub access token via GITHUB_TOKEN environment variable!"
exit 1
fi

file_content_type="application/zip"
asset_path=xournalpp.zip # relative path of asset to upload
curl -o $asset_path https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/build_xournalpp/xournalpp.zip
ver=$(echo $CIRRUS_TAG | sed s/v//) # --> x.y.z

name="xournalpp-$ver-macos_arm64.zip" # --> xournalpp-x.y.z-macos_arm64.zip

echo "Uploading $asset_path as $name ..."
url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=$name"
curl -X POST \
--data-binary @$asset_path \
--header "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: $file_content_type" \
$url_to_upload

0 comments on commit e2775de

Please sign in to comment.