From 516d7f9e314538b4202b54bf1ad34286dcd1d40c Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Tue, 13 Jan 2026 20:10:15 +0300 Subject: [PATCH] steal release script from xash3d-fwgs & update ci/cd --- .github/workflows/main.yml | 32 ++++++++++++++++-------- ci-scripts/make_release.sh | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 11 deletions(-) create mode 100755 ci-scripts/make_release.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83a85b69..521e16f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,14 +1,12 @@ -name: Build Goldleaf - +name: Build & Deploy Goldleaf on: [push, pull_request] - jobs: - Goldleaf: + build: + name: "Build Goldleaf" runs-on: ubuntu-latest container: devkitpro/devkita64:latest - steps: - - uses: actions/checkout@master + - uses: actions/checkout@v6 with: submodules: recursive @@ -32,20 +30,32 @@ jobs: - name: Build and install libnx run: | cd libnx - make install -j$(nproc) + make install -j$(nproc) -l$(nproc) - name: Build libusbhsfs dependencies run: | - make setup -j$(nproc) + make setup -j$(nproc) -l$(nproc) - name: Build Goldleaf run: | python3 arc/arc.py gen_db default+Goldleaf/include/res/res_Account.rc.hpp+Goldleaf/include/res/res_ETicket.rc.hpp+Goldleaf/include/res/res_NS.rc.hpp+Goldleaf/include/res/res_NFP.rc.hpp+Goldleaf/include/res/res_Goldleaf.rc.hpp python3 arc/arc.py gen_cpp rc GLEAF Goldleaf/include/res/res_Generated.gen.hpp - make build -j$(nproc) + make build -j$(nproc) -l$(nproc) - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v6 with: - name: Goldleaf path: Goldleaf/Goldleaf.nro if-no-files-found: error + + release: + name: "Publish release" + runs-on: ubuntu-latest + needs: [build] + if: ${{ github.event_name == 'push' }} + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: Remove old release and upload new release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: bash ci-scripts/make_release.sh "${{ github.repository }}" "${{ github.ref_name }}" diff --git a/ci-scripts/make_release.sh b/ci-scripts/make_release.sh new file mode 100755 index 00000000..16888a72 --- /dev/null +++ b/ci-scripts/make_release.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +if ! command -v gh > /dev/null; then + echo "Install GitHub CLI tool" + exit 1 +fi + +RELEASE_NAME=$(echo -n $1 | sed -e 's/^.*\///g') +BRANCH_NAME=$2 +DEFAULT_BRANCH_NAME=master + +if [ -z "$RELEASE_NAME" ] || [ -z "$BRANCH_NAME" ]; then + echo "Invalid arguments" + exit 1 +fi + +if [ "$BRANCH_NAME" == "$DEFAULT_BRANCH_NAME" ]; then + RELEASE_TAG="continuous" +else + RELEASE_TAG="continuous-$BRANCH_NAME" +fi + +gh release delete "$RELEASE_TAG" \ + --yes \ + --cleanup-tag \ + --repo "$GITHUB_REPOSITORY" || true + +gh run download "$GITHUB_RUN_ID" \ + --dir artifacts/ \ + --repo "$GITHUB_REPOSITORY" + +pushd artifacts/ || exit 1 +echo "Artifacts:" +ls +for i in $(find -mindepth 1 -maxdepth 1 -type d); do + mv "$i"/* . + rmdir "$i" +done +echo "Repackaged artifacts:" +ls -R +popd || exit 1 + +git log -1 --pretty=format:'%h%nBy %aN at %ai' > release-notes + +sleep 10s +gh release create "$RELEASE_TAG" artifacts/* \ + --title "$RELEASE_NAME Continuous $BRANCH_NAME build" \ + --notes-file release-notes \ + --target "$GITHUB_SHA" \ + --repo "$GITHUB_REPOSITORY" \ + --prerelease