From 6745736622440cd1a9cb1bd364c009235b36268c Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Thu, 2 Jun 2022 05:10:17 -0400 Subject: [PATCH] deployment: unify build release action between nightly/deploy (#743) Unifies nightly and deployment workflows using a shared action yml file to avoid as much duplication. Also updates the download-artifact action to v3. --- .github/workflows/build_releases.yml | 321 ++++++++++++++++++++++++ .github/workflows/deployment.yml | 350 +-------------------------- .github/workflows/nightly.yml | 350 +-------------------------- 3 files changed, 334 insertions(+), 687 deletions(-) create mode 100644 .github/workflows/build_releases.yml diff --git a/.github/workflows/build_releases.yml b/.github/workflows/build_releases.yml new file mode 100644 index 00000000..157db397 --- /dev/null +++ b/.github/workflows/build_releases.yml @@ -0,0 +1,321 @@ +# Builds the following releases: +# - Binary releases +# - Debian releases (.deb) +# - MSI installer + +name: "Build Releases" + +on: + workflow_dispatch: + workflow_call: + +env: + CARGO_INCREMENTAL: 0 + +jobs: + build-binaries: + name: "Build binaries" + runs-on: ${{ matrix.info.os }} + container: ${{ matrix.info.container }} + env: + RUST_BACKTRACE: 1 + BTM_GENERATE: true + strategy: + fail-fast: false + matrix: + info: + # ======= Supported targets ======= + # Linux (x64, x86, aarch64) + - { + os: "ubuntu-18.04", + target: "x86_64-unknown-linux-gnu", + cross: false, + } + - { + os: "ubuntu-18.04", + target: "x86_64-unknown-linux-gnu", + cross: false, + container: quay.io/pypa/manylinux2014_x86_64, + suffix: "2-17", + } + - { + os: "ubuntu-18.04", + target: "i686-unknown-linux-gnu", + cross: true, + } + - { + os: "ubuntu-18.04", + target: "x86_64-unknown-linux-musl", + cross: false, + } + - { + os: "ubuntu-18.04", + target: "i686-unknown-linux-musl", + cross: true, + } + - { + os: "ubuntu-18.04", + target: "aarch64-unknown-linux-gnu", + cross: true, + } + - { + os: "ubuntu-18.04", + target: "aarch64-unknown-linux-musl", + cross: true, + } + + # macOS (x64) + - { os: "macOS-latest", target: "x86_64-apple-darwin", cross: false } + + # Windows (x64, x86) + - { + os: "windows-2019", + target: "x86_64-pc-windows-msvc", + cross: false, + } + - { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false } + - { + os: "windows-2019", + target: "x86_64-pc-windows-gnu", + cross: false, + } + + # ======= Unsupported targets ======= + # armv7 + - { + os: "ubuntu-18.04", + target: "armv7-unknown-linux-gnueabihf", + cross: true, + } + - { + os: "ubuntu-18.04", + target: "armv7-unknown-linux-musleabihf", + cross: true, + } + + # PowerPC 64 LE + - { + os: "ubuntu-18.04", + target: "powerpc64le-unknown-linux-gnu", + cross: true, + } + + # Risc-V 64gc + - { + os: "ubuntu-18.04", + target: "riscv64gc-unknown-linux-gnu", + cross: true, + } + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Install toolchain + uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 + with: + profile: minimal + toolchain: stable + override: true + target: ${{ matrix.info.target }} + + - name: Enable Rust cache + uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 + with: + key: ${{ matrix.info.target }} + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy + use-cross: ${{ matrix.info.cross }} + + - name: Bundle release and completion (Windows) + if: matrix.info.os == 'windows-2019' + shell: bash + run: | + cp target/${{ matrix.info.target }}/release/btm.exe btm.exe + 7z a bottom_${{ matrix.info.target }}.zip "btm.exe" + 7z a bottom_${{ matrix.info.target }}.zip "completion" + echo "ASSET=bottom_${{ matrix.info.target }}.zip" >> $GITHUB_ENV + + - name: Bundle release and completion (Linux and macOS) + if: matrix.info.os != 'windows-2019' + shell: bash + run: | + cp target/${{ matrix.info.target }}/release/btm ./btm + tar -czvf bottom_${{ matrix.info.target }}${{ matrix.info.suffix }}.tar.gz btm completion + echo "ASSET=bottom_${{ matrix.info.target }}${{ matrix.info.suffix }}.tar.gz" >> $GITHUB_ENV + + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv ${{ env.ASSET }} release/ + + - name: Compress completion files (Linux x86-64 GNU) + if: matrix.info.target == 'x86_64-unknown-linux-gnu' && matrix.info.container == '' + shell: bash + run: | + tar -C ./completion -czvf completion.tar.gz . + mv completion.tar.gz release/ + + - name: Compress manpage files (Linux x86-64 GNU) + if: matrix.info.target == 'x86_64-unknown-linux-gnu' && matrix.info.container == '' + shell: bash + run: | + gzip ./manpage/btm.1 + tar -C ./manpage -czvf manpage.tar.gz . + mv manpage.tar.gz release/ + + - name: Save release as artifact + uses: actions/upload-artifact@v2 + with: + retention-days: 3 + name: release + path: release + + build-msi: + name: "Build MSI installer" + runs-on: "windows-2019" + env: + RUST_BACKTRACE: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Install Net-Framework-Core + shell: powershell + run: Install-WindowsFeature Net-Framework-Core + + - name: Install wixtoolset + uses: crazy-max/ghaction-chocolatey@87d06bbbd2cfb1835f1820042d356aef4875fb5f # 1.6.0 + with: + args: install -y wixtoolset + + - name: Install toolchain + uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 + with: + profile: minimal + toolchain: stable + override: true + target: x86_64-pc-windows-msvc + + - name: Enable Rust cache + uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 + with: + key: x86_64-pc-windows-msvc-msi + + - name: Build MSI file + shell: powershell + run: | + cargo install cargo-wix --version 0.3.1 --locked + cargo wix init + cargo wix + + - name: Create release directory for artifact, move files + shell: bash + run: | + mkdir release + mv bottom_x86_64_installer.msi release/ + + - name: Save release as artifact + uses: actions/upload-artifact@v2 + with: + retention-days: 3 + name: release + path: release + + build-deb: + name: "Build Debian installers" + runs-on: "ubuntu-18.04" + strategy: + fail-fast: false + matrix: + info: + - { target: "x86_64-unknown-linux-gnu", cross: false, dpkg: amd64 } + - { + target: "aarch64-unknown-linux-gnu", + cross: true, + dpkg: arm64, + container: "ghcr.io/clementtsang/cargo-deb-aarch64-unknown-linux-gnu", + } + - { + target: "armv7-unknown-linux-gnueabihf", + cross: true, + dpkg: armhf, + container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf", + } + env: + RUST_BACKTRACE: 1 + BTM_GENERATE: true + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Install toolchain + uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 + with: + profile: minimal + toolchain: stable + override: true + target: ${{ matrix.info.target }} + + - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --locked --verbose --features deploy --target ${{ matrix.info.target }} + use-cross: ${{ matrix.info.cross }} + + - name: Zip manpage + run: | + gzip ./manpage/btm.1 + + - name: Build Debian release (x86-64) + if: matrix.info.cross == false + run: | + cargo install cargo-deb --version 1.38.0 --locked + cargo deb --no-build --target ${{ matrix.info.target }} + cp ./target/${{ matrix.info.target }}/debian/bottom_*.deb ./bottom_${{ matrix.info.target }}.deb + + - name: Build Debian release (ARM) + if: matrix.info.cross == true + run: | + docker pull ${{ matrix.info.container }} + docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.info.container }} "--variant ${{ matrix.info.dpkg }} --target ${{ matrix.info.target }} --no-build" "/volume" + cp ./target/${{ matrix.info.target }}/debian/bottom-*.deb ./bottom_${{ matrix.info.target }}.deb + + - name: Test Debian release + run: | + dpkg -I ./bottom_${{ matrix.info.target }}.deb + dpkg -I ./bottom_${{ matrix.info.target }}.deb | grep ${{ matrix.info.dpkg }} && echo "Found correct architecture" + + - name: Delete generated Debian folder + run: | + sudo chown $USER ./target/${{ matrix.info.target }}/debian/ 2>/dev/null || true + rm -r ./target/${{ matrix.info.target }}/debian/ + + - name: Create release directory for artifact, move file + shell: bash + run: | + mkdir release + mv bottom_${{ matrix.info.target }}.deb release/ + + - name: Save release as artifact + uses: actions/upload-artifact@v2 + with: + retention-days: 3 + name: release + path: release diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index d24a7607..be46593d 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -1,4 +1,4 @@ -# How we deploy a release. Covers binary builds. Also manages packaging for choco. +# How we deploy a release. Covers binary builds. Also manages packaging for choco. # # Based on https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml @@ -48,344 +48,12 @@ jobs: path: release-version build-release: - name: build-release needs: [initialize-release-job] - runs-on: ${{ matrix.triple.os }} - container: ${{ matrix.triple.container }} - env: - RUST_BACKTRACE: 1 - BTM_GENERATE: true - strategy: - fail-fast: false - matrix: - triple: - # Standard x86-64 stuff, stable - - { - os: "ubuntu-18.04", - target: "x86_64-unknown-linux-gnu", - cross: false, - } - - { - os: "ubuntu-18.04", - target: "x86_64-unknown-linux-gnu", - cross: false, - container: quay.io/pypa/manylinux2014_x86_64, - suffix: "2-17", - } - - { - os: "ubuntu-18.04", - target: "i686-unknown-linux-gnu", - cross: true, - } - - { - os: "ubuntu-18.04", - target: "x86_64-unknown-linux-musl", - cross: false, - } - - { - os: "ubuntu-18.04", - target: "i686-unknown-linux-musl", - cross: true, - } - - { os: "macOS-latest", target: "x86_64-apple-darwin", cross: false } - - { - os: "windows-2019", - target: "x86_64-pc-windows-msvc", - cross: false, - } - - { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false } - - { - os: "windows-2019", - target: "x86_64-pc-windows-gnu", - cross: false, - } - - # aarch64 - - { - os: "ubuntu-18.04", - target: "aarch64-unknown-linux-gnu", - cross: true, - } - - { - os: "ubuntu-18.04", - target: "aarch64-unknown-linux-musl", - cross: true, - } - - # armv7 - - { - os: "ubuntu-18.04", - target: "armv7-unknown-linux-gnueabihf", - cross: true, - } - - { - os: "ubuntu-18.04", - target: "armv7-unknown-linux-musleabihf", - cross: true, - } - - # PowerPC 64 LE - - { - os: "ubuntu-18.04", - target: "powerpc64le-unknown-linux-gnu", - cross: true, - } - - # Risc-V 64gc - - { - os: "ubuntu-18.04", - target: "riscv64gc-unknown-linux-gnu", - cross: true, - } - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Install toolchain - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: stable - override: true - target: ${{ matrix.triple.target }} - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - with: - key: ${{ matrix.triple.target }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --verbose --locked --target=${{ matrix.triple.target }} --features deploy - use-cross: ${{ matrix.triple.cross }} - - - name: Bundle release and completion (Windows) - if: matrix.triple.os == 'windows-2019' - shell: bash - run: | - cp target/${{ matrix.triple.target }}/release/btm.exe btm.exe - 7z a bottom_${{ matrix.triple.target }}.zip "btm.exe" - 7z a bottom_${{ matrix.triple.target }}.zip "completion" - echo "ASSET=bottom_${{ matrix.triple.target }}.zip" >> $GITHUB_ENV - - - name: Bundle release and completion (Linux and macOS) - if: matrix.triple.os != 'windows-2019' - shell: bash - run: | - cp target/${{ matrix.triple.target }}/release/btm ./btm - tar -czvf bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz btm completion - echo "ASSET=bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz" >> $GITHUB_ENV - - - name: Create release directory for artifact, move file - shell: bash - run: | - mkdir release - mv ${{ env.ASSET }} release/ - - - name: Compress completion files (Linux x86-64 GNU) - if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' - shell: bash - run: | - tar -C ./completion -czvf completion.tar.gz . - mv completion.tar.gz release/ - - - name: Compress manpage files (Linux x86-64 GNU) - if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' - shell: bash - run: | - gzip ./manpage/btm.1 - tar -C ./manpage -czvf manpage.tar.gz . - mv manpage.tar.gz release/ - - - name: Save release as artifact - uses: actions/upload-artifact@v2 - with: - retention-days: 3 - name: release - path: release - - build-msi: - name: build-msi - needs: [initialize-release-job] - runs-on: "windows-2019" - env: - RUST_BACKTRACE: 1 - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - uses: actions/setup-python@v2 - - - name: Get release version - uses: actions/download-artifact@v2 - with: - name: release-version - path: release-version - - - name: Set release version - shell: bash - run: | - release_version="$(cat ./release-version/release-version)" - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Validate release version - run: | - echo "Release version: ${{ env.RELEASE_VERSION }}" - - - name: Install Net-Framework-Core (Windows x86-64 MSVC) - shell: powershell - run: Install-WindowsFeature Net-Framework-Core - - - name: Install wixtoolset (Windows x86-64 MSVC) - uses: crazy-max/ghaction-chocolatey@87d06bbbd2cfb1835f1820042d356aef4875fb5f # 1.6.0 - with: - args: install -y wixtoolset - - - name: Install toolchain - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: stable - override: true - target: x86_64-pc-windows-msvc - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - with: - key: x86_64-pc-windows-msvc-msi - - - name: Build msi file - shell: powershell - run: | - cargo install cargo-wix --version 0.3.1 --locked - cargo wix init - cargo wix - - - name: Create release directory for artifact, move files - shell: bash - run: | - mkdir release - mv bottom_x86_64_installer.msi release/ - - - name: Save release as artifact - uses: actions/upload-artifact@v2 - with: - retention-days: 3 - name: release - path: release - - build-deb: - name: build-deb - needs: [initialize-release-job] - runs-on: "ubuntu-18.04" - strategy: - fail-fast: false - matrix: - tuple: - - { target: "x86_64-unknown-linux-gnu", cross: false, dpkg: amd64 } - - { - target: "aarch64-unknown-linux-gnu", - cross: true, - dpkg: arm64, - container: "ghcr.io/clementtsang/cargo-deb-aarch64-unknown-linux-gnu", - } - - { - target: "armv7-unknown-linux-gnueabihf", - cross: true, - dpkg: armhf, - container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf", - } - env: - RUST_BACKTRACE: 1 - BTM_GENERATE: true - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Get release version - uses: actions/download-artifact@v2 - with: - name: release-version - path: release-version - - - name: Set release version - shell: bash - run: | - release_version="$(cat ./release-version/release-version)" - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Validate release version - run: | - echo "Release version: ${{ env.RELEASE_VERSION }}" - - - name: Install toolchain - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: stable - override: true - target: ${{ matrix.tuple.target }} - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --locked --verbose --features deploy --target ${{ matrix.tuple.target }} - use-cross: ${{ matrix.tuple.cross }} - - - name: Zip manpage - run: | - gzip ./manpage/btm.1 - - - name: Build Debian release (x86-64) - if: matrix.tuple.cross == false - run: | - cargo install cargo-deb --version 1.38.0 --locked - cargo deb --no-build --target ${{ matrix.tuple.target }} - cp ./target/${{ matrix.tuple.target }}/debian/bottom_*.deb ./bottom_${{ matrix.tuple.target }}.deb - - - name: Build Debian release (ARM) - if: matrix.tuple.cross == true - run: | - docker pull ${{ matrix.tuple.container }} - docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.tuple.container }} "--variant ${{ matrix.tuple.dpkg }} --target ${{ matrix.tuple.target }} --no-build" "/volume" - cp ./target/${{ matrix.tuple.target }}/debian/bottom-*.deb ./bottom_${{ matrix.tuple.target }}.deb - - - name: Test Debian release - run: | - dpkg -I ./bottom_${{ matrix.tuple.target }}.deb - dpkg -I ./bottom_${{ matrix.tuple.target }}.deb | grep ${{ matrix.tuple.dpkg }} && echo "Found correct architecture" - - - name: Delete generated Debian folder - run: | - sudo chown $USER ./target/${{ matrix.tuple.target }}/debian/ 2>/dev/null || true - rm -r ./target/${{ matrix.tuple.target }}/debian/ - - - name: Create release directory for artifact, move file - shell: bash - run: | - mkdir release - mv bottom_${{ matrix.tuple.target }}.deb release/ - - - name: Save release as artifact - uses: actions/upload-artifact@v2 - with: - retention-days: 3 - name: release - path: release + uses: ./.github/workflows/build_releases.yml generate-choco: needs: [build-release] - name: generate-choco + name: "Generate Chocolatey files" runs-on: ubuntu-latest steps: - name: Checkout repository @@ -393,10 +61,8 @@ jobs: with: fetch-depth: 1 - - uses: actions/setup-python@v2 - - name: Get release version - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: release-version path: release-version @@ -412,7 +78,7 @@ jobs: echo "Release version: ${{ env.RELEASE_VERSION }}" - name: Get release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: release path: release @@ -437,10 +103,10 @@ jobs: upload-release: name: upload-release runs-on: ubuntu-latest - needs: [generate-choco, build-deb, build-msi] + needs: [generate-choco, build-release] steps: - name: Get release version - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: release-version path: release-version @@ -456,7 +122,7 @@ jobs: echo "Release version: ${{ env.RELEASE_VERSION }}" - name: Get release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: release path: release diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 430873eb..d4defa60 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,4 +1,4 @@ -# Creates nightly deployment builds for main targets. Note this does not cover package distribution channels, +# Creates nightly deployment builds for main targets. Note this does not cover package distribution channels, # such as choco. name: nightly @@ -30,360 +30,20 @@ jobs: elif [[ "${{ github.event.inputs.isMock }}" == "mock" ]]; then echo "This is a mock run." else - echo "This is NOT a mock run. Watch for the generated files!" + echo "This is NOT a mock run. Watch for the generated files!" fi - - name: Save version number to artifact - run: echo "nightly" > release-version - - - name: Upload release-version as artifact - uses: actions/upload-artifact@v2 - with: - retention-days: 1 - name: release-version - path: release-version - build-release: - name: build-release needs: [initialize-job] - runs-on: ${{ matrix.triple.os }} - container: ${{ matrix.triple.container }} - env: - RUST_BACKTRACE: 1 - BTM_GENERATE: true - strategy: - fail-fast: false - matrix: - triple: - # Standard x86-64 stuff, stable - - { - os: "ubuntu-18.04", - target: "x86_64-unknown-linux-gnu", - cross: false, - } - - { - os: "ubuntu-18.04", - target: "x86_64-unknown-linux-gnu", - cross: false, - container: quay.io/pypa/manylinux2014_x86_64, - suffix: "2-17", - } - - { - os: "ubuntu-18.04", - target: "i686-unknown-linux-gnu", - cross: true, - } - - { - os: "ubuntu-18.04", - target: "x86_64-unknown-linux-musl", - cross: false, - } - - { - os: "ubuntu-18.04", - target: "i686-unknown-linux-musl", - cross: true, - } - - { os: "macOS-latest", target: "x86_64-apple-darwin", cross: false } - - { - os: "windows-2019", - target: "x86_64-pc-windows-msvc", - cross: false, - } - - { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false } - - { - os: "windows-2019", - target: "x86_64-pc-windows-gnu", - cross: false, - } - - # aarch64 - - { - os: "ubuntu-18.04", - target: "aarch64-unknown-linux-gnu", - cross: true, - } - - { - os: "ubuntu-18.04", - target: "aarch64-unknown-linux-musl", - cross: true, - } - - # armv7 - - { - os: "ubuntu-18.04", - target: "armv7-unknown-linux-gnueabihf", - cross: true, - } - - { - os: "ubuntu-18.04", - target: "armv7-unknown-linux-musleabihf", - cross: true, - } - - # PowerPC 64 LE - - { - os: "ubuntu-18.04", - target: "powerpc64le-unknown-linux-gnu", - cross: true, - } - - # Risc-V 64gc - - { - os: "ubuntu-18.04", - target: "riscv64gc-unknown-linux-gnu", - cross: true, - } - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Install toolchain - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: stable - override: true - target: ${{ matrix.triple.target }} - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - with: - key: ${{ matrix.triple.target }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --locked --verbose --target=${{ matrix.triple.target }} --features deploy - use-cross: ${{ matrix.triple.cross }} - - - name: Bundle release and completion (Windows) - if: matrix.triple.os == 'windows-2019' - shell: bash - run: | - cp target/${{ matrix.triple.target }}/release/btm.exe btm.exe - 7z a bottom_${{ matrix.triple.target }}.zip "btm.exe" - 7z a bottom_${{ matrix.triple.target }}.zip "completion" - echo "ASSET=bottom_${{ matrix.triple.target }}.zip" >> $GITHUB_ENV - - - name: Bundle release and completion (Linux and macOS) - if: matrix.triple.os != 'windows-2019' - shell: bash - run: | - cp target/${{ matrix.triple.target }}/release/btm ./btm - tar -czvf bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz btm completion - echo "ASSET=bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz" >> $GITHUB_ENV - - - name: Create release directory for artifact, move file - shell: bash - run: | - mkdir release - mv ${{ env.ASSET }} release/ - - - name: Compress completion files (Linux x86-64 GNU) - if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' - shell: bash - run: | - tar -C ./completion -czvf completion.tar.gz . - mv completion.tar.gz release/ - - - name: Compress manpage files (Linux x86-64 GNU) - if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' - shell: bash - run: | - gzip ./manpage/btm.1 - tar -C ./manpage -czvf manpage.tar.gz . - mv manpage.tar.gz release/ - - - name: Save release files as artifacts - uses: actions/upload-artifact@v2 - with: - retention-days: 1 - name: release - path: release - - build-msi: - name: build-msi - needs: [initialize-job] - runs-on: "windows-2019" - env: - RUST_BACKTRACE: 1 - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Get release version - uses: actions/download-artifact@v2 - with: - name: release-version - path: release-version - - - name: Set release version - shell: bash - run: | - release_version="$(cat ./release-version/release-version)" - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Validate release version - run: | - echo "Release version: ${{ env.RELEASE_VERSION }}" - - - name: Install Net-Framework-Core - shell: powershell - run: Install-WindowsFeature Net-Framework-Core - - - name: Install wixtoolset - uses: crazy-max/ghaction-chocolatey@87d06bbbd2cfb1835f1820042d356aef4875fb5f # 1.6.0 - with: - args: install -y wixtoolset - - - name: Install toolchain - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: stable - override: true - target: x86_64-pc-windows-msvc - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - with: - key: x86_64-pc-windows-msvc-msi - - - name: Build msi file - shell: powershell - run: | - cargo install cargo-wix --version 0.3.1 --locked - cargo wix init - cargo wix - - - name: Create release directory for artifact, move file - shell: bash - run: | - mkdir release - mv bottom_x86_64_installer.msi release/ - - - name: Save msi file as artifacts - uses: actions/upload-artifact@v2 - with: - retention-days: 1 - name: release - path: release - - build-deb: - name: build-deb - needs: [initialize-job] - runs-on: "ubuntu-18.04" - strategy: - fail-fast: false - matrix: - tuple: - - { target: "x86_64-unknown-linux-gnu", cross: false, dpkg: amd64 } - - { - target: "aarch64-unknown-linux-gnu", - cross: true, - dpkg: arm64, - container: "ghcr.io/clementtsang/cargo-deb-aarch64-unknown-linux-gnu", - } - - { - target: "armv7-unknown-linux-gnueabihf", - cross: true, - dpkg: armhf, - container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf", - } - env: - RUST_BACKTRACE: 1 - BTM_GENERATE: true - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Get release version - uses: actions/download-artifact@v2 - with: - name: release-version - path: release-version - - - name: Set release version - shell: bash - run: | - release_version="$(cat ./release-version/release-version)" - echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - - name: Validate release version - run: | - echo "Release version: ${{ env.RELEASE_VERSION }}" - - - name: Install toolchain - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: stable - override: true - target: ${{ matrix.tuple.target }} - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --locked --verbose --features deploy --target ${{ matrix.tuple.target }} - use-cross: ${{ matrix.tuple.cross }} - - - name: Zip manpage - run: | - gzip ./manpage/btm.1 - - - name: Build Debian release (x86-64) - if: matrix.tuple.cross == false - run: | - cargo install cargo-deb --version 1.38.0 --locked - cargo deb --no-build --target ${{ matrix.tuple.target }} - cp ./target/${{ matrix.tuple.target }}/debian/bottom_*.deb ./bottom_${{ matrix.tuple.target }}.deb - - - name: Build Debian release (ARM) - if: matrix.tuple.cross == true - run: | - docker pull ${{ matrix.tuple.container }} - docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.tuple.container }} "--variant ${{ matrix.tuple.dpkg }} --target ${{ matrix.tuple.target }} --no-build" "/volume" - cp ./target/${{ matrix.tuple.target }}/debian/bottom-*.deb ./bottom_${{ matrix.tuple.target }}.deb - - - name: Test Debian release - run: | - dpkg -I ./bottom_${{ matrix.tuple.target }}.deb - dpkg -I ./bottom_${{ matrix.tuple.target }}.deb | grep ${{ matrix.tuple.dpkg }} && echo "Found correct architecture" - - - name: Delete generated Debian folder - run: | - sudo chown $USER ./target/${{ matrix.tuple.target }}/debian/ 2>/dev/null || true - rm -r ./target/${{ matrix.tuple.target }}/debian/ - - - name: Create release directory for artifact, move file - shell: bash - run: | - mkdir release - mv bottom_${{ matrix.tuple.target }}.deb release/ - - - name: Save Debian file as artifacts - uses: actions/upload-artifact@v2 - with: - retention-days: 1 - name: release - path: release + uses: ./.github/workflows/build_releases.yml upload-release: name: upload-release runs-on: ubuntu-latest - needs: [build-release, build-deb, build-msi] + needs: [build-release] steps: - name: Get release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: release path: release