From 0efbfbeccbc4cd4c76301a6389060564c87ce463 Mon Sep 17 00:00:00 2001 From: Benoist <14257866+Kenzzer@users.noreply.github.com> Date: Tue, 30 Sep 2025 17:19:00 +0200 Subject: [PATCH] Add release workflow (#40) * Add release workflow * Restrict to direct push * Update dependent CI * Correct main CI * Optimize workflow dispatch * Restrict to 'workflow_call' * Don't rely on 'workflow_call' * Actually use UPLOAD_PASSWORD * add the -git tag * use short sha * fix platform naming mistake * Add branch param to upload url * Setup PR workflow * modify the trigger * Add branch name debug + renable PR workflow * Try %22 * No quotes! --- .github/workflows/ci.yml | 64 +++++++++++-------------- .github/workflows/pull_request.yml | 12 +++++ .github/workflows/release.yml | 76 ++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/pull_request.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 983f3c1..58dad97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,54 +1,46 @@ name: CI on: workflow_dispatch: - pull_request: - branches: - - master - - overhaul - - push: - branches: - - master - - overhaul + workflow_call: + inputs: + release: + type: boolean + required: true + default: false jobs: cache: uses: ./.github/workflows/cache.yml + + build-options: + runs-on: ubuntu-latest + outputs: + exclude: ${{ steps.set.outputs.exclude }} + steps: + - id: set + run: | + echo "exclude=[${{ inputs.release && '{"runners": { "upload": false } }' || '' }}]" >> $GITHUB_OUTPUT build: name: Build - needs: cache + needs: [ cache, build-options ] strategy: fail-fast: false matrix: - os: [ 'ubuntu-22.04', 'ubuntu-latest', 'windows-latest' ] - include: - # we need to ship ubuntu 22.04 because of glibc reasons - - os: ubuntu-22.04 - #cc: clang-8 - #cxx: clang++-8 - cc: clang - cxx: clang++ - upload: true - upload-artifact-name: accelerator_linux - - os: ubuntu-latest - cc: clang - cxx: clang++ - upload: false - upload-artifact-name: none - - os: windows-latest - cc: msvc - cxx: msvc - upload: true - upload-artifact-name: accelerator_windows + runners: [ + { os: ubuntu-22.04, cc: clang, cxx: clang++, upload: true, upload-artifact-name: accelerator_linux }, + { os: ubuntu-latest, cc: clang, cxx: clang++, upload: false }, + { os: windows-latest, cc: msvc, cxx: msvc, upload: true, upload-artifact-name: accelerator_windows } + ] + exclude: ${{ fromJson(needs.build-options.outputs.exclude) }} uses: ./.github/workflows/build-extension.yml with: - os: ${{ matrix.os }} - cc: ${{ matrix.cc }} - cxx: ${{ matrix.cxx }} - upload: ${{ matrix.upload }} - upload-artifact-name: ${{ matrix.upload-artifact-name }} + os: ${{ matrix.runners.os }} + cc: ${{ matrix.runners.cc }} + cxx: ${{ matrix.runners.cxx }} + upload: ${{ matrix.runners.upload }} + upload-artifact-name: ${{ matrix.runners.upload-artifact-name }} cache-key: ${{ needs.cache.outputs.key }} - cache-dir: ${{ needs.cache.outputs.dir }} + cache-dir: ${{ needs.cache.outputs.dir }} \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..e2cdce8 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,12 @@ +name: Pull Request + +on: + workflow_dispatch: + pull_request: + branches: [ master ] + +jobs: + main-ci: + uses: ./.github/workflows/ci.yml + with: + release: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d725a0f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,76 @@ +name: Release + +on: + workflow_dispatch: + push: + branches: [ master, release_ci ] + +jobs: + main-ci: + uses: ./.github/workflows/ci.yml + with: + release: true + + release: + permissions: write-all + runs-on: ubuntu-latest + needs: [ main-ci ] + + env: + PROJECT: 'accelerator' + steps: + - run: sudo apt-get install -y tree + + - uses: actions/checkout@v4 + name: Repository checkout + with: + fetch-depth: 0 + path: repository + + - name: Download Linux release + uses: actions/download-artifact@v5 + with: + name: accelerator_linux + path: linux + + - name: Download Windows release + uses: actions/download-artifact@v5 + with: + name: accelerator_windows + path: windows + + - name: Zip release again + run: | + cd repository + read -r PRODUCT_VERSION < ./product.version + REV_COUNT=$(git rev-list --count HEAD) + REV_SHA=$(git rev-parse --short HEAD) + cd .. + WINDOWS_ZIP="${{ env.PROJECT }}-$PRODUCT_VERSION-git$REV_COUNT-$REV_SHA-windows.zip" + LINUX_ZIP="${{ env.PROJECT }}-$PRODUCT_VERSION-git$REV_COUNT-$REV_SHA-linux.zip" + zip -r ${WINDOWS_ZIP} windows + zip -r ${LINUX_ZIP} linux + + echo "WINDOWS_ZIP=${WINDOWS_ZIP}" >> $GITHUB_ENV + echo "LINUX_ZIP=${LINUX_ZIP}" >> $GITHUB_ENV + + - name: Upload release + shell: bash + run: | + echo "Begin upload for branch (${{ github.ref_name }})" + AUTHORIZATION="$(echo -n 'builds:${{ secrets.UPLOAD_PASSWORD }}' | base64)" + echo "::add-mask::${AUTHORIZATION}" + + echo "Uploading ${{ env.WINDOWS_ZIP }}" + HTTP_CODE=$(curl -XPOST -H "Authorization: Basic ${AUTHORIZATION}" -H "Content-Type: application/zip" --output /dev/null --silent --write-out "%{http_code}" --data-binary "@${{ env.WINDOWS_ZIP }}" "https://builds.limetech.io/upload.php?project=${{ env.PROJECT }}&branch=${{ github.ref_name }}&filename=${{ env.WINDOWS_ZIP }}") + if test ${HTTP_CODE} -ne 200; then + echo "Upload failed with HTTP Code: ${HTTP_CODE}" + exit 1 + fi + echo "Uploading ${{ env.LINUX_ZIP }}" + HTTP_CODE=$(curl -XPOST -H "Authorization: Basic ${AUTHORIZATION}" -H "Content-Type: application/zip" --output /dev/null --silent --write-out "%{http_code}" --data-binary "@${{ env.LINUX_ZIP }}" "https://builds.limetech.io/upload.php?project=${{ env.PROJECT }}&branch=${{ github.ref_name }}&filename=${{ env.LINUX_ZIP }}") + if test ${HTTP_CODE} -ne 200; then + echo "Upload failed with HTTP Code: ${HTTP_CODE}" + exit 1 + fi + echo "Upload successful!"