Merge pull request #1382 from Nheko-Reborn/gitlab_artifact_updates

Create github release from tags and upload artifacts as assets
pull/1400/head
Joseph Donofry 2 years ago committed by GitHub
commit 9bc50fa908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .ci/macos/notarize.sh
  2. 67
      .ci/update-github-release.sh
  3. 39
      .gitlab-ci.yml
  4. 3
      appveyor.yml

@ -97,7 +97,7 @@ done
VERSION=${CI_COMMIT_SHORT_SHA} VERSION=${CI_COMMIT_SHORT_SHA}
if [ -n "$VERSION" ]; then if [ -n "$VERSION" ]; then
mv nheko.dmg "nheko-${VERSION}_${PLAT}.dmg" mv nheko.dmg "nheko-${VERSION}-${PLAT}.dmg"
mkdir artifacts mkdir -p artifacts
cp "nheko-${VERSION}_${PLAT}.dmg" artifacts/ cp "nheko-${VERSION}-${PLAT}.dmg" artifacts/
fi fi

@ -0,0 +1,67 @@
#!/bin/sh
if [ -z "$CI_COMMIT_TAG" ]; then
echo "CI_COMMIT_TAG is unset or empty; exiting"
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 \
-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
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.
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\":${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 \
-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
echo "Getting 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')"
ls -la .
echo "Uploading artifacts"
for file in ./artifacts/*; do
name="${file##*/}"
echo "Uploading $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 "@$file"
done
# TODO: AppVeyor stuffs?

@ -1,3 +1,8 @@
stages:
- build
- sign
- deploy
variables: variables:
CCACHE_COMPILERCHECK: content CCACHE_COMPILERCHECK: content
CCACHE_DIR: "${CI_PROJECT_DIR}/.ccache" CCACHE_DIR: "${CI_PROJECT_DIR}/.ccache"
@ -125,7 +130,7 @@ build-macos:
- if : '$CI_PIPELINE_TRIGGERED == null' - if : '$CI_PIPELINE_TRIGGERED == null'
artifacts: artifacts:
paths: 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 name: nheko-${CI_COMMIT_SHORT_SHA}-macos-app
expose_as: 'macos-app' expose_as: 'macos-app'
public: false public: false
@ -136,7 +141,7 @@ build-macos:
- "${CCACHE_DIR}" - "${CCACHE_DIR}"
codesign-macos: codesign-macos:
stage: deploy stage: sign
tags: [macos] tags: [macos]
variables: variables:
PLAT: "intel" PLAT: "intel"
@ -146,19 +151,19 @@ codesign-macos:
- export PATH=/usr/local/opt/qt@5/bin/:${PATH} - export PATH=/usr/local/opt/qt@5/bin/:${PATH}
- ./.ci/macos/notarize.sh - ./.ci/macos/notarize.sh
after_script: 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: needs:
- job: build-macos - job: build-macos
optional: true # optional since we want to be able to also trigger this job from cirrus ci for apple silicon builds. optional: true # optional since we want to be able to also trigger this job from cirrus ci for apple silicon builds.
rules: rules:
- if : '$CI_PIPELINE_TRIGGERED && $CI_COMMIT_REF_PROTECTED == "true"' - if : '$CI_PIPELINE_TRIGGERED && $CI_COMMIT_REF_PROTECTED == "true"'
variables: variables:
PLAT: "m1" PLAT: "apple_silicon"
- if : '$CI_COMMIT_BRANCH == "master"' - if : '$CI_COMMIT_BRANCH == "master"'
- if : $CI_COMMIT_TAG - if : $CI_COMMIT_TAG
artifacts: artifacts:
paths: paths:
- artifacts/nheko-${CI_COMMIT_SHORT_SHA}_${PLAT}.dmg - artifacts/nheko-${CI_COMMIT_SHORT_SHA}-${PLAT}.dmg
- /tmp/notarize* - /tmp/notarize*
name: nheko-${CI_COMMIT_SHORT_SHA}-macos name: nheko-${CI_COMMIT_SHORT_SHA}-macos
@ -181,6 +186,7 @@ build-flatpak-amd64:
after_script: after_script:
- bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-amd64.flatpak - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-amd64.flatpak
- (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true - (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true
- (cd .. && mkdir -p artifacts && cp build-flatpak/nheko-amd64.flatpak artifacts/) || true
rules: rules:
- if : '$CI_PIPELINE_TRIGGERED == null' - if : '$CI_PIPELINE_TRIGGERED == null'
cache: cache:
@ -189,7 +195,7 @@ build-flatpak-amd64:
- build-flatpak/.flatpak-builder/ - build-flatpak/.flatpak-builder/
artifacts: artifacts:
expose_as: 'flatpak-amd64' expose_as: 'flatpak-amd64'
paths: ['build-flatpak/nheko-amd64.flatpak'] paths: ['artifacts/nheko-amd64.flatpak']
name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-amd64 name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-amd64
build-flatpak-arm64: build-flatpak-arm64:
@ -212,6 +218,7 @@ build-flatpak-arm64:
after_script: after_script:
- bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-arm64.flatpak - bash ./.ci/upload-nightly-gitlab.sh build-flatpak/nheko-arm64.flatpak
- (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true - (cd ./scripts && ./upload-to-flatpak-repo.sh ../build-flatpak/repo) || true
- (cd .. && mkdir -p artifacts && cp build-flatpak/nheko-arm64.flatpak artifacts/) || true
rules: rules:
- if : '$CI_PIPELINE_TRIGGERED == null' - if : '$CI_PIPELINE_TRIGGERED == null'
cache: cache:
@ -220,7 +227,7 @@ build-flatpak-arm64:
- build-flatpak/.flatpak-builder/ - build-flatpak/.flatpak-builder/
artifacts: artifacts:
expose_as: 'flatpak-arm64' expose_as: 'flatpak-arm64'
paths: ['build-flatpak/nheko-arm64.flatpak'] paths: ['artifacts/nheko-arm64.flatpak']
name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-arm64 name: flatpak-${CI_COMMIT_REF_NAME}-${VERSION}-arm64
appimage-amd64: appimage-amd64:
@ -274,12 +281,13 @@ appimage-amd64:
- mkdir -p AppDir/usr/lib/x86_64-linux-gnu AppDir/lib/x86_64-linux-gnu - mkdir -p AppDir/usr/lib/x86_64-linux-gnu AppDir/lib/x86_64-linux-gnu
- appimage-builder --skip-test - appimage-builder --skip-test
after_script: after_script:
- mkdir -p artifacts && cp nheko-latest-x86_64.AppImage artifacts/
- bash ./.ci/upload-nightly-gitlab.sh nheko-latest-x86_64.AppImage - bash ./.ci/upload-nightly-gitlab.sh nheko-latest-x86_64.AppImage
rules: rules:
- if : '$CI_PIPELINE_TRIGGERED == null' - if : '$CI_PIPELINE_TRIGGERED == null'
artifacts: artifacts:
paths: paths:
- 'nheko-latest-x86_64.AppImage' - 'artifacts/nheko-latest-x86_64.AppImage'
expire_in: 1 week expire_in: 1 week
expose_as: 'appimage-amd64' expose_as: 'appimage-amd64'
cache: cache:
@ -303,3 +311,18 @@ linting:
rules: rules:
- if : '$CI_PIPELINE_TRIGGERED == null' - if : '$CI_PIPELINE_TRIGGERED == null'
github-release:
stage: deploy
image: alpine:latest
tags: [docker]
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
dependencies:
- appimage-amd64
- build-flatpak-arm64
- build-flatpak-amd64
- codesign-macos
before_script:
- apk update && apk add jq curl perl
script:
- ./.ci/update-github-release.sh

@ -109,9 +109,6 @@ after_build:
- copy nheko-installer.exe nheko-%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%-installer.exe - copy nheko-installer.exe nheko-%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%-installer.exe
- ps: .\.ci\upload-nightly.ps1 - ps: .\.ci\upload-nightly.ps1
on_success:
- if "%APPVEYOR_REPO_TAG%" == "true" (curl -T nheko-%APPVEYOR_REPO_TAG_NAME%-installer.exe -uredsky17:%BINTRAY_APIKEY% https://api.bintray.com/content/nheko-reborn/nheko/%APPVEYOR_REPO_TAG_NAME%/nheko/%APPVEYOR_REPO_TAG_NAME%/)
deploy: deploy:
- description: "Development builds" - description: "Development builds"
provider: GitHub provider: GitHub

Loading…
Cancel
Save