From d1d335333196ff520ceaac290e7d48f8af53e33e Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Thu, 17 Aug 2023 23:09:35 +0200 Subject: [PATCH] refactor: Upgrade cargo-dist to 0.1.0 release (#229) --- .github/workflows/release.yml | 63 ++++++++++++++++++++--------------- Cargo.toml | 7 ++-- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1221eccf..814975079 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,6 @@ +# Copyright 2022-2023, axodotdev +# SPDX-License-Identifier: MIT or Apache-2.0 +# # CI that: # # * checks for a Git Tag that looks like a release @@ -51,20 +54,23 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 - - name: Install Rust - run: rustup update 1.70.0 --no-self-update && rustup default 1.70.0 + with: + submodules: recursive - name: Install cargo-dist - run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.6-prerelease.3/cargo-dist-v0.0.6-prerelease.3-installer.sh | sh + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" + - name: Install packages (Linux) + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev - id: create-release run: | - cargo dist manifest --tag=${{ github.ref_name }} --artifacts=all --no-local-paths --output-format=json > dist-manifest.json - echo "dist manifest ran successfully" + cargo dist plan --tag=${{ github.ref_name }} --output-format=json > dist-manifest.json + echo "dist plan ran successfully" cat dist-manifest.json # Create the Github Releaseā„¢ based on what cargo-dist thinks it should be - ANNOUNCEMENT_TITLE=$(cat dist-manifest.json | jq --raw-output ".announcement_title") - IS_PRERELEASE=$(cat dist-manifest.json | jq --raw-output ".announcement_is_prerelease") - cat dist-manifest.json | jq --raw-output ".announcement_github_body" > new_dist_announcement.md + ANNOUNCEMENT_TITLE=$(jq --raw-output ".announcement_title" dist-manifest.json) + IS_PRERELEASE=$(jq --raw-output ".announcement_is_prerelease" dist-manifest.json) + jq --raw-output ".announcement_github_body" dist-manifest.json > new_dist_announcement.md gh release create ${{ github.ref_name }} --draft --prerelease="$IS_PRERELEASE" --title="$ANNOUNCEMENT_TITLE" --notes-file=new_dist_announcement.md echo "created announcement!" @@ -73,7 +79,7 @@ jobs: echo "uploaded manifest!" # Disable all the upload-artifacts tasks if we have no actual releases - HAS_RELEASES=$(cat dist-manifest.json | jq --raw-output ".releases != null") + HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json) echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT" # Build and packages all the things @@ -82,34 +88,35 @@ jobs: needs: create-release if: ${{ needs.create-release.outputs.has-releases == 'true' }} strategy: + fail-fast: false matrix: # For these target platforms include: - - os: ubuntu-20.04 - dist-args: --artifacts=global - install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.6-prerelease.3/cargo-dist-v0.0.6-prerelease.3-installer.sh | sh - - os: macos-11 - dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin - install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.6-prerelease.3/cargo-dist-v0.0.6-prerelease.3-installer.sh | sh - - os: ubuntu-20.04 - dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu - install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.6-prerelease.3/cargo-dist-v0.0.6-prerelease.3-installer.sh | sh - - os: windows-2019 - dist-args: --artifacts=local --target=x86_64-pc-windows-msvc - install-dist: irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.6-prerelease.3/cargo-dist-v0.0.6-prerelease.3-installer.ps1 | iex + - os: "ubuntu-20.04" + dist-args: "--artifacts=global" + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" + - os: "macos-11" + dist-args: "--artifacts=local --target=aarch64-apple-darwin" + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" + - os: "macos-11" + dist-args: "--artifacts=local --target=x86_64-apple-darwin" + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" + - os: "windows-2019" + dist-args: "--artifacts=local --target=x86_64-pc-windows-msvc" + install-dist: "irm https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.ps1 | iex" + - os: "ubuntu-20.04" + dist-args: "--artifacts=local --target=x86_64-unknown-linux-gnu" + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" runs-on: ${{ matrix.os }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 - - name: Install Rust - run: rustup update 1.70.0 --no-self-update && rustup default 1.70.0 + with: + submodules: recursive - name: Install cargo-dist run: ${{ matrix.install-dist }} - - name: Install packages (Linux) - if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev - name: Run cargo-dist # This logic is a bit janky because it's trying to be a polyglot between # powershell and bash since this will run on windows, macos, and linux! @@ -122,7 +129,7 @@ jobs: cat dist-manifest.json # Parse out what we just built and upload it to the Github Releaseā„¢ - cat dist-manifest.json | jq --raw-output ".artifacts[]?.path | select( . != null )" > uploads.txt + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json > uploads.txt echo "uploading..." cat uploads.txt gh release upload ${{ github.ref_name }} $(cat uploads.txt) @@ -138,6 +145,8 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: mark release as non-draft run: | gh release edit ${{ github.ref_name }} --draft=false diff --git a/Cargo.toml b/Cargo.toml index 2795bc625..ef0ec5528 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,15 +80,14 @@ lto = "thin" # Config for 'cargo dist' [workspace.metadata.dist] # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.0.5" -# The preferred Rust toolchain to use in CI (rustup toolchain syntax) -rust-toolchain-version = "1.68.2" +cargo-dist-version = "0.1.0" # CI backends to support (see 'cargo dist generate-ci') ci = ["github"] # The installers to generate for each app installers = ["shell", "powershell", "npm"] # Target platforms to build apps for (Rust target-triple syntax) targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"] -# Format to use for tarballs/zips -- .tar.gz is currently required for the npm installer +# The archive format to use for windows builds (defaults .zip) windows-archive = ".tar.gz" +# The archive format to use for non-windows builds (defaults .tar.xz) unix-archive = ".tar.gz"