Skip to content

Commit

Permalink
refactor: Upgrade cargo-dist to 0.1.0 release (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
frol authored Aug 17, 2023
1 parent 1c9a7a6 commit d1d3353
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
63 changes: 36 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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!"
Expand All @@ -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
Expand All @@ -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!
Expand All @@ -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)
Expand All @@ -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
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit d1d3353

Please sign in to comment.