Bump actions/download-artifact from 4 to 5 (#38) #94
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Zero-Clause BSD License | |
| # Copyright (C) 2023 Toitware ApS. | |
| # Permission to use, copy, modify, and/or distribute this software for any | |
| # purpose with or without fee is hereby granted. | |
| # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
| # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| # FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
| # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
| # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
| # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
| # PERFORMANCE OF THIS SOFTWARE. | |
| name: CI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| sign_macos: | |
| description: Sign the macOS binary | |
| type: boolean | |
| required: true | |
| default: false | |
| sign_windows: | |
| description: Sign the Windows binary | |
| type: boolean | |
| required: true | |
| default: false | |
| release: | |
| types: [published] | |
| push: | |
| branches: | |
| - "*" | |
| - "*/*" | |
| env: | |
| TOIT_VERSION: v2.0.0-alpha.170 | |
| APP_NAME: partitions | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-latest, macos-latest, windows-latest ] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Toit | |
| shell: bash | |
| run: | | |
| if [[ "$RUNNER_OS" = "Windows" ]]; then | |
| BIN_EXTENSION=".exe" | |
| fi | |
| echo "BIN_EXTENSION=$BIN_EXTENSION" >> $GITHUB_ENV | |
| - name: Install Toit | |
| uses: toitlang/action-setup@v1 | |
| with: | |
| toit-version: ${{ env.TOIT_VERSION }} | |
| - name: Build binaries | |
| shell: bash | |
| run: | | |
| make build | |
| - name: Run tests | |
| shell: bash | |
| run: | | |
| make test | |
| - name: Tar.gz Linux executable | |
| if: runner.os == 'Linux' | |
| run: | | |
| tar c -zvf build/${{env.APP_NAME}}-linux.tar.gz -C build ${{env.APP_NAME}} | |
| - name: Sign Windows binary | |
| if: runner.os == 'Windows' && (github.event_name == 'release' || inputs.sign_windows) | |
| uses: toitlang/action-sign-server@26db6e4021bfbd79af777d15964f1ab70bcfd3a4 # v1.0.7 | |
| with: | |
| uri: ${{ vars.CERTUM_URI }} | |
| password: ${{ secrets.CERTUM_PWD }} | |
| path: build/${{env.APP_NAME}}.exe | |
| - name: Zip Windows binary | |
| if: runner.os == 'Windows' | |
| run: | | |
| cd build | |
| 7z a ${{env.APP_NAME}}-windows.zip ${{env.APP_NAME}}.exe | |
| - name: Upload binary artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ runner.os }} | |
| path: build/${{env.APP_NAME}}${{ env.BIN_EXTENSION }} | |
| - name: Upload Linux tar.gz | |
| if: runner.os == 'Linux' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-Linux-tar | |
| path: build/${{env.APP_NAME}}-linux.tar.gz | |
| - name: Upload Windows zip | |
| if: runner.os == 'Windows' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-Windows-zip | |
| path: build/${{env.APP_NAME}}-windows.zip | |
| - name: Upload release Linux executable | |
| if: github.event_name == 'release' && runner.os == 'Linux' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: build/${{env.APP_NAME}}-linux.tar.gz | |
| tag: ${{ github.event.release.tag_name }} | |
| overwrite: true | |
| - name: Upload release Windows executable | |
| if: github.event_name == 'release' && runner.os == 'Windows' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: build/${{env.APP_NAME}}-windows.zip | |
| tag: ${{ github.event.release.tag_name }} | |
| overwrite: true | |
| sign_macos: | |
| runs-on: macos-latest | |
| needs: [build] | |
| if: github.event_name == 'release' || inputs.sign_macos | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: binaries-macOS | |
| path: in | |
| - name: Install dependencies | |
| run: | | |
| set -e | |
| brew install create-dmg | |
| brew install zip | |
| - name: Copy to build | |
| run: | | |
| mkdir -p build | |
| cp in/${{env.APP_NAME}} build/${{env.APP_NAME}} | |
| - name: Setup binary rights | |
| run: | | |
| chmod +x build/${{env.APP_NAME}} | |
| - name: Sign and notarize | |
| uses: toitlang/[email protected] | |
| with: | |
| certificate: ${{ secrets.MACOS_CERTIFICATE }} | |
| certificate-password: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
| username: ${{ secrets.AC_USERNAME }} | |
| password: ${{ secrets.AC_PASSWORD }} | |
| apple-team-id: ${{ vars.MACOS_TEAM_ID }} | |
| # Signs in place. | |
| app-path: build/${{env.APP_NAME}} | |
| - name: Create out folder | |
| run: | | |
| mkdir -p out | |
| - name: Create a DMG | |
| run: | | |
| # Use an empty directory as source so we don't accidentally add other files than the | |
| # ${{env.APP_NAME}} binary. | |
| set -e | |
| mkdir empty | |
| create-dmg \ | |
| --volname "${{env.APP_NAME}}" \ | |
| --add-file ${{env.APP_NAME}} build/${{env.APP_NAME}} 0 0 \ | |
| out/${{env.APP_NAME}}-macos.dmg \ | |
| empty | |
| - name: Create a ZIP | |
| run: | | |
| zip -j out/${{env.APP_NAME}}-macos.zip build/${{env.APP_NAME}} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-macOS-signed | |
| path: ./out | |
| - name: Upload release macOS executable DMG | |
| if: github.event_name == 'release' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: out/${{env.APP_NAME}}-macos.dmg | |
| tag: ${{ github.event.release.tag_name }} | |
| overwrite: true | |
| - name: Upload release macOS executable ZIP | |
| if: github.event_name == 'release' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: out/${{env.APP_NAME}}-macos.zip | |
| tag: ${{ github.event.release.tag_name }} | |
| overwrite: true |