From 9b2476a7625f309658e97a2bfe4c9f69010797b1 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Wed, 12 Feb 2025 15:33:42 +0100 Subject: [PATCH] fix: integrate appimage artifact into release workflow (#1846) * Integrate appimage artifact into release workflow * Add upload of appimage as release * Undo temporary disabled --- .github/workflows/ci-appimage.yml | 129 -------------------------- .github/workflows/ci-release.yml | 148 ++++++++++++++++++++++++------ 2 files changed, 121 insertions(+), 156 deletions(-) delete mode 100644 .github/workflows/ci-appimage.yml diff --git a/.github/workflows/ci-appimage.yml b/.github/workflows/ci-appimage.yml deleted file mode 100644 index a27340ef..00000000 --- a/.github/workflows/ci-appimage.yml +++ /dev/null @@ -1,129 +0,0 @@ -name: CI AppImage - -on: - pull_request: - paths-ignore: - - 'doc/**' - - '**.md' - - '**.rst' - - '**.txt' - release: - types: [published] - workflow_dispatch: - -jobs: - - build: - name: Assemble for Linux - - # Oldest supported by Alire+GitHub to increase AppImage back-compatibility - # Unfortunately we depend on the static elaboration model of recent GNATs - runs-on: ubuntu-22.04 - - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - submodules: true - - - name: Install FSF toolchain - run: sudo apt-get install -y gnat-10 gprbuild - - - name: Check toolchain architecture - uses: mosteo-actions/gnat-toolchain-arch-checker@v1 - - - name: Set up gcc on the PATH to be gcc-10 - run: | - mkdir -p $HOME/.local/bin - ln -s /usr/bin/gcc-10 $HOME/.local/bin/gcc - - - name: Install Python 3.x (required for the testsuite) - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Run test script - run: scripts/ci-github.sh - shell: bash - env: - BRANCH: ${{ github.base_ref }} - INDEX: "" - - - name: Upload logs (if failed) - if: failure() - uses: actions/upload-artifact@v4 - with: - name: e3-log-linux.zip - path: testsuite/out - - - name: Retrieve upload URL for the release - if: (github.event_name == 'release') - id: get_release - uses: bruceadams/get-release@v1.3.2 - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: Get release version - if: (github.event_name == 'release') - id: get_version - uses: battila7/get-version-action@v2 - - - name: Get ref version - if: (github.event_name != 'release') - id: get_ref - run: echo "::set-output name=short_sha::$(echo ${{ github.sha }} | cut -c1-8)" - - ############ - # AppImage # - ############ - - - name: Install AppImage dependencies (libfuse2) - shell: bash - run: | - sudo add-apt-repository universe - sudo apt-get install -y libfuse2 - - - name: Install AppImage's linuxdeploy - uses: miurahr/install-linuxdeploy-action@v1 - with: - plugins: appimage - - - name: Copy license into AppImage - run: | - mkdir -p AppDir - cp LICENSE.txt AppDir/ - - - name: Create AppImage - run: > - linuxdeploy-x86_64.AppImage --appdir AppDir -e bin/alr - -d resources/alr.desktop -i resources/alr.png --output appimage - - - name: Rename AppImage - run: mv alr*AppImage alr.AppImage - - - name: Test AppImage without the toolchain installed - run: | - chmod +x ./alr.AppImage - sudo apt-get remove -y gnat-10 gprbuild - which gnat || { echo "Toolchain purged"; ./alr.AppImage version; } - - - name: Upload AppImage asset - if: (github.event_name == 'release') - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: alr.AppImage - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-x86_64.AppImage - asset_content_type: application/x-elf - - # When not a release we upload as a plain artifact, just to make sure that - # this works as expected. Also this way the AppImage is available for - # regular PRs for easy testing. - - name: Upload as artifact (when not a release) - if: (github.event_name != 'release') - uses: actions/upload-artifact@v4 - with: - name: alr-${{ steps.get_ref.outputs.short_sha }}-x86_64.AppImage.zip - path: alr.AppImage diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index be7dfca6..c6feedbc 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -32,7 +32,7 @@ jobs: ######### build: - name: build on ${{ matrix.platform.id }} + name: Build on ${{ matrix.platform.id }} runs-on: ${{ matrix.platform.os }} @@ -133,6 +133,7 @@ jobs: # Joins the two binaries for macOS in a single universal one build-macos-universal: + name: Create macOS universal binary runs-on: macos-latest needs: build steps: @@ -164,6 +165,30 @@ jobs: bin/alr LICENSE.txt + ################ + # release-info # + ################ + + release-info: + name: Info for release uploads + if: github.event_name == 'release' + runs-on: ubuntu-latest + outputs: + upload-url: ${{ steps.get_release.outputs.upload_url }} + version-without-v: ${{ steps.get_version.outputs.version-without-v }} + + steps: + - name: Retrieve upload URL for the release + id: get_release + uses: bruceadams/get-release@v1.3.2 + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Get release version + id: get_version + uses: battila7/get-version-action@v2 + + ########### # release # ########### @@ -172,7 +197,7 @@ jobs: release: name: Release on ${{ matrix.platform.id }} if: github.event_name == 'release' - needs: [build, build-macos-universal] + needs: [build, build-macos-universal, release-info] runs-on: ${{ matrix.platform.os }} strategy: @@ -215,24 +240,14 @@ jobs: if: matrix.platform.os == 'windows-latest' run: 7z a alr-bin.zip bin/alr.exe LICENSE.txt - - name: Retrieve upload URL for the release - id: get_release - uses: bruceadams/get-release@v1.3.2 - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: Get release version - id: get_version - uses: battila7/get-version-action@v2 - - name: Upload binary assets uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.get_release.outputs.upload_url }} + upload_url: ${{ needs.release-info.outputs.upload-url }} asset_path: alr-bin.zip - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-${{ matrix.platform.id }}.zip + asset_name: alr-${{ needs.release-info.outputs.version-without-v }}-bin-${{ matrix.platform.id }}.zip asset_content_type: application/zip ##################### @@ -318,7 +333,7 @@ jobs: release-windows-installer: name: Release Windows installer if: github.event_name == 'release' - needs: [build, windows-installer] + needs: [build, release-info, windows-installer] runs-on: windows-latest steps: @@ -337,22 +352,101 @@ jobs: - name: Rename installer run: copy installer/alire-*.exe installer/alire-install.exe - - name: Retrieve upload URL for the release - id: get_release - uses: bruceadams/get-release@v1.3.2 - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: Get release version - id: get_version - uses: battila7/get-version-action@v2 - - name: Upload installer asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.get_release.outputs.upload_url }} + upload_url: ${{ needs.release-info.outputs.upload-url }} asset_path: installer/alire-install.exe - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-installer-x86_64-windows.exe + asset_name: alr-${{ needs.release-info.outputs.version-without-v }}-installer-x86_64-windows.exe asset_content_type: application/vnd.microsoft.portable-executable + + ############ + # appimage # + ############ + + appimage: + name: Create AppImage + needs: build + runs-on: ubuntu-22.04 + outputs: + short_sha: ${{ steps.get_ref.outputs.short_sha }} + + steps: + + - name: Check out repository + uses: actions/checkout@v4 + # No need for submodules, but we need some resources for the appimage + + - name: Retrieve artifact + uses: actions/download-artifact@v4 + with: + name: alr-bin-x86_64-linux.zip + + - name: Install AppImage dependencies (libfuse2) + shell: bash + run: | + sudo add-apt-repository universe + sudo apt-get install -y libfuse2 + + - name: Install AppImage's linuxdeploy + uses: miurahr/install-linuxdeploy-action@v1 + with: + plugins: appimage + + - name: Copy license into AppImage + run: | + mkdir -p AppDir + cp LICENSE.txt AppDir/ + + - name: Create AppImage + run: > + linuxdeploy-x86_64.AppImage --appdir AppDir -e bin/alr + -d resources/alr.desktop -i resources/alr.png --output appimage + + - name: Rename AppImage + run: mv alr*AppImage alr.AppImage + + - name: Test AppImage without the toolchain installed + run: | + chmod +x ./alr.AppImage + which gnat || { echo "Toolchain purged"; ./alr.AppImage version; } + + - name: Get ref version + id: get_ref + run: echo "::set-output name=short_sha::$(echo ${{ github.sha }} | cut -c1-8)" + + - name: Upload as artifact + uses: actions/upload-artifact@v4 + with: + name: alr-${{ steps.get_ref.outputs.short_sha }}-x86_64.AppImage.zip + path: alr.AppImage + + #################### + # release-appimage # + #################### + + release-appimage: + name: Release AppImage + if: github.event_name == 'release' + needs: [appimage, release-info] + runs-on: ubuntu-22.04 + + steps: + + - name: Retrieve binary artifact + uses: actions/download-artifact@v4 + with: + name: alr-${{needs.appimage.outputs.short_sha}}-x86_64.AppImage.zip + + - name: Upload AppImage asset + if: (github.event_name == 'release') + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.release-info.outputs.upload-url }} + asset_path: alr.AppImage + asset_name: alr-${{ needs.release-info.outputs.version-without-v }}-x86_64.AppImage + asset_content_type: application/x-elf \ No newline at end of file -- 2.39.5