From b219d6a6b6c2f1a28c96daf418a3418d2da17959 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Mon, 20 Feb 2023 17:17:37 -0500 Subject: Create github release from tags and upload artifacts as assets --- .ci/update-github-release.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .ci/update-github-release.sh (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh new file mode 100644 index 00000000..49f5e18a --- /dev/null +++ b/.ci/update-github-release.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +if [ -z "$CI_COMMIT_TAG" ]; then + echo "CI_COMMIT_TAG is unset or empty; exiting" + exit 1 +fi + + +# check if we already have a release for the current tag or not +http_code=$(curl \ + -s \ + -o /dev/null \ + -I \ + -w "%{http_code}" \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") + +if [ "$http_code" = "404" ]; then + # Doing a 'fresh' release, not just updating the assets. + release_json="$(curl \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/Nheko-Reborn/nheko/releases \ + -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"Description of the release\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" +elif [ "$http_code" = "200" ]; then + # Updating a release (probably because of cirrus-ci or so) + release_json=$(curl \ + -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") +fi + +upload_url="$(echo "$release_json" | jq ".upload-url")" +# get rid of the 'hypermedia' stuff at the end and use a 'real' URL +upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')" + +for file in ./artifacts/*; do + name="${file##*/}" + [ -e "$file" ] && curl \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/octet-stream" \ + "${upload_url}=$name" \ + --data-binary "@$name" +done + + +# TODO: AppVeyor stuffs? \ No newline at end of file -- cgit 1.5.1 From f3966bd1ce8b3417d4091a4f87e71078ced52007 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Mon, 20 Feb 2023 19:16:43 -0500 Subject: Generate release notes from CHANGELOG.md --- .ci/update-github-release.sh | 3 ++- .gitlab-ci.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh index 49f5e18a..488063ca 100644 --- a/.ci/update-github-release.sh +++ b/.ci/update-github-release.sh @@ -18,6 +18,7 @@ http_code=$(curl \ "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") if [ "$http_code" = "404" ]; then + release_notes="$(perl -0777 -ne '/.*?(## .*?)\n(## |\Z)/s && print $1' CHANGELOG.md | jq -R -s '.')" # Doing a 'fresh' release, not just updating the assets. release_json="$(curl \ -X POST \ @@ -25,7 +26,7 @@ if [ "$http_code" = "404" ]; then -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/Nheko-Reborn/nheko/releases \ - -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"Description of the release\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" + -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"${release_notes}\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" elif [ "$http_code" = "200" ]; then # Updating a release (probably because of cirrus-ci or so) release_json=$(curl \ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9ee6744d..c4df66e9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -317,4 +317,4 @@ github-release: before_script: - apk update && apk add jq script: - - ./.ci/update-github-release.sh \ No newline at end of file + - ./.ci/update-github-release.sh -- cgit 1.5.1 From 9a0320dd504f4593577820e108388bb51abdbf0d Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Mon, 27 Feb 2023 16:21:39 -0500 Subject: Make github script executable --- .ci/update-github-release.sh | 0 .gitlab-ci.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 .ci/update-github-release.sh (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh old mode 100644 new mode 100755 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f08c8ef1..c6079f52 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -218,7 +218,7 @@ build-flatpak-arm64: - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-arm64.flatpak - (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true rules: - - if : '$CI_PIPELINE_TRIGGERED == null' + - if : '$CI_PIPELINE_TRIGGERED == 123456' cache: key: "$CI_JOB_NAME" paths: -- cgit 1.5.1 From b4148d9ca5d09d9e9aa34b1cbe2f6d9257b527dd Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Mon, 27 Feb 2023 18:02:31 -0500 Subject: Maybe fix key naming issue --- .ci/update-github-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh index 488063ca..aed99ad1 100755 --- a/.ci/update-github-release.sh +++ b/.ci/update-github-release.sh @@ -37,7 +37,7 @@ elif [ "$http_code" = "200" ]; then "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") fi -upload_url="$(echo "$release_json" | jq ".upload-url")" +upload_url="$(echo "$release_json" | jq '."upload-url"')" # get rid of the 'hypermedia' stuff at the end and use a 'real' URL upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')" -- cgit 1.5.1 From 4fc14b62cf8f228c3baf6e138e4e31175d24451f Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Tue, 28 Feb 2023 10:59:47 -0500 Subject: Add more logging to CI script --- .ci/update-github-release.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh index aed99ad1..ca7aab50 100755 --- a/.ci/update-github-release.sh +++ b/.ci/update-github-release.sh @@ -5,7 +5,7 @@ if [ -z "$CI_COMMIT_TAG" ]; then exit 1 fi - +echo "Checking if release exists for ${CI_COMMIT_TAG}" # check if we already have a release for the current tag or not http_code=$(curl \ -s \ @@ -18,7 +18,10 @@ http_code=$(curl \ "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") if [ "$http_code" = "404" ]; then + echo "Release does not exist... getting notes from CHANGELOG.md" release_notes="$(perl -0777 -ne '/.*?(## .*?)\n(## |\Z)/s && print $1' CHANGELOG.md | jq -R -s '.')" + + echo "Creating new release for ${CI_COMMIT_TAG}" # Doing a 'fresh' release, not just updating the assets. release_json="$(curl \ -X POST \ @@ -28,6 +31,7 @@ if [ "$http_code" = "404" ]; then https://api.github.com/repos/Nheko-Reborn/nheko/releases \ -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"${release_notes}\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" elif [ "$http_code" = "200" ]; then + echo "Release already exists for ${CI_COMMIT_TAG}; Updating" # Updating a release (probably because of cirrus-ci or so) release_json=$(curl \ -s \ @@ -37,12 +41,16 @@ elif [ "$http_code" = "200" ]; then "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") fi +echo "Getting upload URL..." upload_url="$(echo "$release_json" | jq '."upload-url"')" # get rid of the 'hypermedia' stuff at the end and use a 'real' URL +echo "Upload URL (hypermedia): ${upload_url}" upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')" +echo "Uploading artifacts" for file in ./artifacts/*; do name="${file##*/}" + echo "Uploading ${name}" [ -e "$file" ] && curl \ -X POST \ -H "Accept: application/vnd.github+json" \ @@ -50,7 +58,7 @@ for file in ./artifacts/*; do -H "X-GitHub-Api-Version: 2022-11-28" \ -H "Content-Type: application/octet-stream" \ "${upload_url}=$name" \ - --data-binary "@$name" + --data-binary "@$file" done -- cgit 1.5.1 From 701058ef211ef457ef49149fea0a054883f621a4 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Tue, 28 Feb 2023 12:04:55 -0500 Subject: Release notes are already quoted --- .ci/update-github-release.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh index ca7aab50..d51b4dd9 100755 --- a/.ci/update-github-release.sh +++ b/.ci/update-github-release.sh @@ -18,8 +18,9 @@ http_code=$(curl \ "https://api.github.com/repos/Nheko-Reborn/nheko/releases/tags/$CI_COMMIT_TAG") if [ "$http_code" = "404" ]; then - echo "Release does not exist... getting notes from CHANGELOG.md" + echo "Release does not exist... getting notes from CHANGELOG.md:" release_notes="$(perl -0777 -ne '/.*?(## .*?)\n(## |\Z)/s && print $1' CHANGELOG.md | jq -R -s '.')" + echo "$release_notes" echo "Creating new release for ${CI_COMMIT_TAG}" # Doing a 'fresh' release, not just updating the assets. @@ -29,7 +30,7 @@ if [ "$http_code" = "404" ]; then -H "Authorization: Bearer ${GITHUB_AUTH_TOKEN}"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/Nheko-Reborn/nheko/releases \ - -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":\"${release_notes}\",\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" + -d "{\"tag_name\":\"${CI_COMMIT_TAG}\",\"target_commitish\":\"master\",\"name\":\"${CI_COMMIT_TAG}\",\"body\":${release_notes},\"draft\":true,\"prerelease\":true,\"generate_release_notes\":false}")" elif [ "$http_code" = "200" ]; then echo "Release already exists for ${CI_COMMIT_TAG}; Updating" # Updating a release (probably because of cirrus-ci or so) -- cgit 1.5.1 From 51c9245c6a283e0ee3a091888dd647d1c929de78 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Tue, 28 Feb 2023 12:53:27 -0500 Subject: Fix upload_url json key --- .ci/update-github-release.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to '.ci') diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh index d51b4dd9..ac643987 100755 --- a/.ci/update-github-release.sh +++ b/.ci/update-github-release.sh @@ -43,15 +43,16 @@ elif [ "$http_code" = "200" ]; then fi echo "Getting upload URL..." -upload_url="$(echo "$release_json" | jq '."upload-url"')" +upload_url="$(echo "$release_json" | jq '."upload_url"')" # get rid of the 'hypermedia' stuff at the end and use a 'real' URL echo "Upload URL (hypermedia): ${upload_url}" upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')" +ls -la . echo "Uploading artifacts" for file in ./artifacts/*; do name="${file##*/}" - echo "Uploading ${name}" + echo "Uploading $file" [ -e "$file" ] && curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -- cgit 1.5.1 From 9a1a065c61f1d24700e208a299f787d8270c0788 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Tue, 28 Feb 2023 13:39:11 -0500 Subject: Put releasable artifacts into artifacts dir --- .ci/macos/notarize.sh | 2 +- .gitlab-ci.yml | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to '.ci') diff --git a/.ci/macos/notarize.sh b/.ci/macos/notarize.sh index 2757d44c..cb3d3ef7 100755 --- a/.ci/macos/notarize.sh +++ b/.ci/macos/notarize.sh @@ -98,6 +98,6 @@ VERSION=${CI_COMMIT_SHORT_SHA} if [ -n "$VERSION" ]; then mv nheko.dmg "nheko-${VERSION}_${PLAT}.dmg" - mkdir artifacts + mkdir -p artifacts cp "nheko-${VERSION}_${PLAT}.dmg" artifacts/ fi \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd62ce16..690cab7f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -130,7 +130,7 @@ build-macos: - if : '$CI_PIPELINE_TRIGGERED == null' artifacts: paths: - - build/nheko.app + - build/nheko.app # not putting this in 'artifacts' subdir because we don't want to put it on releases name: nheko-${CI_COMMIT_SHORT_SHA}-macos-app expose_as: 'macos-app' public: false @@ -186,6 +186,7 @@ build-flatpak-amd64: after_script: - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-amd64.flatpak - (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true + - (cd $CI_BUILDS_DIR && mkdir -p artifacts && cp build-flatpak/nheko-arm64.flatpak artifacts/) || true rules: - if : '$CI_PIPELINE_TRIGGERED == null' cache: @@ -194,7 +195,7 @@ build-flatpak-amd64: - build-flatpak/.flatpak-builder/ artifacts: expose_as: 'flatpak-amd64' - paths: ['build-flatpak/nheko-amd64.flatpak'] + paths: ['artifacts/nheko-amd64.flatpak'] name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-amd64 build-flatpak-arm64: @@ -217,6 +218,7 @@ build-flatpak-arm64: after_script: - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-arm64.flatpak - (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true + - (cd $CI_BUILDS_DIR && mkdir -p artifacts && cp build-flatpak/nheko-arm64.flatpak artifacts/) || true rules: - if : '$CI_PIPELINE_TRIGGERED == "123456"' cache: @@ -225,7 +227,7 @@ build-flatpak-arm64: - build-flatpak/.flatpak-builder/ artifacts: expose_as: 'flatpak-arm64' - paths: ['build-flatpak/nheko-arm64.flatpak'] + paths: ['artifacts/nheko-arm64.flatpak'] name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-arm64 appimage-amd64: @@ -279,12 +281,13 @@ appimage-amd64: - mkdir -p AppDir/usr/lib/x86_64-linux-gnu AppDir/lib/x86_64-linux-gnu - appimage-builder --skip-test after_script: + - mkdir -p artifacts && cp nheko-latest-x86_64.AppImage artifacts/ - bash ./.ci/upload-nightly-gitlab.sh nheko-latest-x86_64.AppImage rules: - if : '$CI_PIPELINE_TRIGGERED == null' artifacts: paths: - - 'nheko-latest-x86_64.AppImage' + - 'artifacts/nheko-latest-x86_64.AppImage' expire_in: 1 week expose_as: 'appimage-amd64' cache: @@ -314,6 +317,9 @@ github-release: tags: [docker] rules: - if: '$CI_COMMIT_TAG =~ /^test\d+\.\d+\.\d+$/' + dependencies: + - build + - sign before_script: - apk update && apk add jq curl perl script: -- cgit 1.5.1 From 7a8bfe49400c18eb288952a7b834c057fa652c3b Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Tue, 28 Feb 2023 16:16:24 -0500 Subject: Fix macOS artifact names and fix jq quotes issue --- .ci/macos/notarize.sh | 4 ++-- .ci/update-github-release.sh | 2 +- .gitlab-ci.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to '.ci') diff --git a/.ci/macos/notarize.sh b/.ci/macos/notarize.sh index cb3d3ef7..345f4828 100755 --- a/.ci/macos/notarize.sh +++ b/.ci/macos/notarize.sh @@ -97,7 +97,7 @@ done VERSION=${CI_COMMIT_SHORT_SHA} if [ -n "$VERSION" ]; then - mv nheko.dmg "nheko-${VERSION}_${PLAT}.dmg" + mv nheko.dmg "nheko-${VERSION}-${PLAT}.dmg" mkdir -p artifacts - cp "nheko-${VERSION}_${PLAT}.dmg" artifacts/ + cp "nheko-${VERSION}-${PLAT}.dmg" artifacts/ fi \ No newline at end of file diff --git a/.ci/update-github-release.sh b/.ci/update-github-release.sh index ac643987..234c1f41 100755 --- a/.ci/update-github-release.sh +++ b/.ci/update-github-release.sh @@ -43,7 +43,7 @@ elif [ "$http_code" = "200" ]; then fi echo "Getting upload URL..." -upload_url="$(echo "$release_json" | jq '."upload_url"')" +upload_url="$(echo "$release_json" | jq -r '."upload_url"')" # get rid of the 'hypermedia' stuff at the end and use a 'real' URL echo "Upload URL (hypermedia): ${upload_url}" upload_url="$(echo "$upload_url" | sed 's/{?name,label\}/?name/g')" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92e11338..460d9c9c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -151,7 +151,7 @@ codesign-macos: - export PATH=/usr/local/opt/qt@5/bin/:${PATH} - ./.ci/macos/notarize.sh after_script: - - ./.ci/upload-nightly-gitlab.sh artifacts/nheko-${CI_COMMIT_SHORT_SHA}_${PLAT}.dmg + - ./.ci/upload-nightly-gitlab.sh artifacts/nheko-${CI_COMMIT_SHORT_SHA}-${PLAT}.dmg needs: - job: build-macos optional: true # optional since we want to be able to also trigger this job from cirrus ci for apple silicon builds. -- cgit 1.5.1