From cbb4941e937627ed9ff18f95f6fa1e1294797ae6 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 14 Aug 2023 20:43:07 +0200 Subject: [PATCH 01/10] wow shiny new cargo-dist CI! --- .github/workflows/release.yml | 146 ++++++++++++++++++++++++++++++++++ Cargo.toml | 16 ++++ 2 files changed, 162 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..2c23c81782 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,146 @@ +# Copyright 2022-2023, axodotdev +# SPDX-License-Identifier: MIT or Apache-2.0 +# +# CI that: +# +# * checks for a Git Tag that looks like a release +# * creates a Github Release™ and fills in its text +# * builds artifacts with cargo-dist (executable-zips, installers) +# * uploads those artifacts to the Github Release™ +# +# Note that the Github Release™ will be created before the artifacts, +# so there will be a few minutes where the release has no artifacts +# and then they will slowly trickle in, possibly failing. To make +# this more pleasant we mark the release as a "draft" until all +# artifacts have been successfully uploaded. This allows you to +# choose what to do with partial successes and avoids spamming +# anyone with notifications before the release is actually ready. +name: Release + +permissions: + contents: write + +# This task will run whenever you push a git tag that looks like a version +# like "v1", "v1.2.0", "v0.1.0-prerelease01", "my-app-v1.0.0", etc. +# The version will be roughly parsed as ({PACKAGE_NAME}-)?v{VERSION}, where +# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION +# must be a Cargo-style SemVer Version. +# +# If PACKAGE_NAME is specified, then we will create a Github Release™ for that +# package (erroring out if it doesn't have the given version or isn't cargo-dist-able). +# +# If PACKAGE_NAME isn't specified, then we will create a Github Release™ for all +# (cargo-dist-able) packages in the workspace with that version (this is mode is +# intended for workspaces with only one dist-able package, or with all dist-able +# packages versioned/released in lockstep). +# +# If you push multiple tags at once, separate instances of this workflow will +# spin up, creating an independent Github Release™ for each one. +# +# If there's a prerelease-style suffix to the version then the Github Release™ +# will be marked as a prerelease. +on: + push: + tags: + - '*-?v[0-9]+*' + +jobs: + # Create the Github Release™ so the packages have something to be uploaded to + create-release: + runs-on: ubuntu-latest + outputs: + has-releases: ${{ steps.create-release.outputs.has-releases }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" + - id: create-release + run: | + 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=$(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!" + + # Upload the manifest to the Github Release™ + gh release upload ${{ github.ref_name }} dist-manifest.json + echo "uploaded manifest!" + + # Disable all the upload-artifacts tasks if we have no actual releases + HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json) + echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT" + + # Build and packages all the things + upload-artifacts: + # Let the initial task tell us to not run (currently very blunt) + needs: create-release + if: ${{ needs.create-release.outputs.has-releases == 'true' }} + strategy: + fail-fast: false + matrix: + # For these target platforms + include: + - 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 + with: + submodules: recursive + - name: Install cargo-dist + run: ${{ matrix.install-dist }} + - 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! + # The two platforms don't agree on how to talk about env vars but they + # do agree on 'cat' and '$()' so we use that to marshal values between commands. + run: | + # Actually do builds and make zips and whatnot + cargo dist build --tag=${{ github.ref_name }} --output-format=json ${{ matrix.dist-args }} > dist-manifest.json + echo "dist ran successfully" + cat dist-manifest.json + + # Parse out what we just built and upload it to the Github Release™ + 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) + echo "uploaded!" + + # Mark the Github Release™ as a non-draft now that everything has succeeded! + publish-release: + # Only run after all the other tasks, but it's ok if upload-artifacts was skipped + needs: [create-release, upload-artifacts] + if: ${{ always() && needs.create-release.result == 'success' && (needs.upload-artifacts.result == 'skipped' || needs.upload-artifacts.result == 'success') }} + runs-on: ubuntu-latest + env: + 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 a9d9d41ee6..84552f95df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,19 @@ default-members = [ "bindgen-cli", "bindgen-tests", ] + +# Config for 'cargo dist' +[workspace.metadata.dist] +# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) +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 = [] +# 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"] + +# The profile that 'cargo dist' will build with +[profile.dist] +inherits = "release" +lto = "thin" From fdef160b775f7bc62ff65c0079256dd172727fe1 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 14 Aug 2023 21:58:47 +0200 Subject: [PATCH 02/10] cargo-dist: include installers --- .github/workflows/release.yml | 3 +++ Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c23c81782..bccdf09c8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,6 +89,9 @@ jobs: 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.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" diff --git a/Cargo.toml b/Cargo.toml index 84552f95df..c57dbe8dac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ 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 = [] +installers = ["shell", "powershell"] # 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"] From 82a9070fee4f2e514a2c7a4fd92a8a4b6830af8a Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 14 Aug 2023 23:15:58 +0200 Subject: [PATCH 03/10] tests_expectations is not to be published Makes it play well with cargo-release, where we would get the following: error: tests_expectations is missing the following fields: license || license-file documentation || homepage || repository --- Cargo.lock | 2 +- bindgen-tests/tests/expectations/Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b44aab8eb9..5cf46b2214 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -638,7 +638,7 @@ dependencies = [ [[package]] name = "tests_expectations" -version = "0.1.0" +version = "0.0.0" dependencies = [ "block", "libloading", diff --git a/bindgen-tests/tests/expectations/Cargo.toml b/bindgen-tests/tests/expectations/Cargo.toml index bf7da25349..adb95d56d2 100644 --- a/bindgen-tests/tests/expectations/Cargo.toml +++ b/bindgen-tests/tests/expectations/Cargo.toml @@ -1,13 +1,14 @@ [package] name = "tests_expectations" description = "bindgen results when ran on ../headers/*" -version = "0.1.0" +version = "0.0.0" authors = [ "Jyun-Yan You ", "Emilio Cobos Álvarez ", "The Servo project developers", ] edition = "2018" +publish = false [dependencies] block = "0.1" From 0f9cc93179bcc8f55234048cc65bff3bd7082b89 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 14 Aug 2023 23:40:50 +0200 Subject: [PATCH 04/10] add config for cargo-release --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index c57dbe8dac..f7b664c0ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,11 @@ installers = ["shell", "powershell"] # 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"] +# Config for 'cargo release' +[workspace.metadata.release] +shared-version = true +tag-name = "v{{version}}" + # The profile that 'cargo dist' will build with [profile.dist] inherits = "release" From 7e41109e15ad35afc15b21b3fe9190cce7baf74b Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 28 Aug 2023 18:52:16 +0200 Subject: [PATCH 05/10] too long to fit easy --- Cargo.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f7b664c0ef..cbf6c515f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,12 @@ ci = ["github"] # The installers to generate for each app installers = ["shell", "powershell"] # 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"] +targets = [ + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "aarch64-apple-darwin", +] # Config for 'cargo release' [workspace.metadata.release] From fdecb58913700362e6078d53bc07cfc07ffe2833 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 28 Aug 2023 22:15:19 +0200 Subject: [PATCH 06/10] add some docs --- CONTRIBUTING.md | 34 +++++++++++++++++++++++++++++----- Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4ec1a4c834..96d3d5af29 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -552,10 +552,14 @@ $ npm install doctoc $ ./node_modules/doctoc/doctoc.js CHANGELOG.md ``` -### Bumping the version numbers. +### Bumping the version numbers -Bump version numbers as needed. Run tests just to ensure everything is working -as expected. +Use `cargo release` (from `cargo install cargo-release`) to automate things: + +- For a feature release, `cargo minor` (will bump v0.62.1 to v0.63.0) +- For a patch release, `cargo patch` (will bump v0.63.0 to v0.63.1) + +Run tests just to ensure everything is working as expected. ### Merge to `main` @@ -565,7 +569,13 @@ important fix) you can skip this. ### Publish and add a git tag for the right commit -Once you're in the right commit, do: +Once you're in the right commit, do `cargo release --execute`. + +``` +cargo release [path|minor] --execute +cargo release --execute +``` +This does the equivalent of the following: ``` $ git tag -a v0.62.1 # With the right version of course @@ -573,9 +583,23 @@ $ pushd bindgen && cargo publish && popd $ pushd bindgen-cli && cargo publish && popd $ git push --tags upstream # To publish the tag ``` + ### Create a new release on Github -See [Releasing projects on Github](https://docs.github.com/en/repositories/releasing-projects-on-github) +The release will be automated with the help of `.github/workflows/release.yml`, +and will only be created when all tests succeed. +While the tests are still running, +a draft GitHub release will be created, +to avoid notifying watchers of the repo should a CI step fail. +If everything succeeds, +bindgen cli installers for Linux/MacOS and Windows will be created, +as well as tarballs. +See `[workspace.metadata.dist]` section in Cargo.toml for the configuration. + +To update the configuration: +``` +cargo dist init # from `cargo install cargo-dist` +cargo dist generate-ci # to update .github/workflows/release.yml [prettyplease]: https://github.com/dtolnay/prettyplease diff --git a/Cargo.toml b/Cargo.toml index cbf6c515f3..64a9120e94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ targets = [ # Config for 'cargo release' [workspace.metadata.release] -shared-version = true +shared-version = true # ensures published packages share the same version tag-name = "v{{version}}" # The profile that 'cargo dist' will build with From b6d0b8f7a934c8985618b31bbf5415fad97e37a1 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 30 Aug 2023 06:11:13 +0200 Subject: [PATCH 07/10] fix docs --- CONTRIBUTING.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 96d3d5af29..d226e58cec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -556,8 +556,8 @@ $ ./node_modules/doctoc/doctoc.js CHANGELOG.md Use `cargo release` (from `cargo install cargo-release`) to automate things: -- For a feature release, `cargo minor` (will bump v0.62.1 to v0.63.0) -- For a patch release, `cargo patch` (will bump v0.63.0 to v0.63.1) +- For a feature release, `cargo release minor --execute` (will bump v0.62.1 to v0.63.0) +- For a patch release, `cargo release patch --execute` (will bump v0.63.0 to v0.63.1) Run tests just to ensure everything is working as expected. @@ -569,10 +569,10 @@ important fix) you can skip this. ### Publish and add a git tag for the right commit -Once you're in the right commit, do `cargo release --execute`. +Once you're in the right commit, do. ``` -cargo release [path|minor] --execute +cargo release [patch|minor] --execute cargo release --execute ``` This does the equivalent of the following: @@ -597,9 +597,11 @@ bindgen cli installers for Linux/MacOS and Windows will be created, as well as tarballs. See `[workspace.metadata.dist]` section in Cargo.toml for the configuration. -To update the configuration: +To update the release configuration: + ``` -cargo dist init # from `cargo install cargo-dist` +cargo dist init # from "cargo install cargo-dist" cargo dist generate-ci # to update .github/workflows/release.yml +``` [prettyplease]: https://github.com/dtolnay/prettyplease From eec9383e8b83617287b3ae1fd3575e14b3a873c0 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 30 Aug 2023 06:15:25 +0200 Subject: [PATCH 08/10] fix docs --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d226e58cec..4b94d79be6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -569,7 +569,7 @@ important fix) you can skip this. ### Publish and add a git tag for the right commit -Once you're in the right commit, do. +Once you're in the right commit, do: ``` cargo release [patch|minor] --execute From 063334ce9d4c4442a6f057d4c73c53411b94c753 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 31 Aug 2023 22:34:43 +0200 Subject: [PATCH 09/10] doc clarification --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b94d79be6..e6439e1262 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -597,7 +597,8 @@ bindgen cli installers for Linux/MacOS and Windows will be created, as well as tarballs. See `[workspace.metadata.dist]` section in Cargo.toml for the configuration. -To update the release configuration: +To update the release configuration, +when a new cargo-dist is available: ``` cargo dist init # from "cargo install cargo-dist" From 58c4d3142e93d079ab987329bd61836cb90ff7f2 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 31 Aug 2023 22:36:17 +0200 Subject: [PATCH 10/10] bump cargo-dist --- .github/workflows/release.yml | 91 +++++++++++++++++++++++------------ Cargo.toml | 2 +- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bccdf09c8d..e0631ca88a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,10 @@ # CI that: # # * checks for a Git Tag that looks like a release -# * creates a Github Release™ and fills in its text -# * builds artifacts with cargo-dist (executable-zips, installers) +# * creates a draft Github Release™ and fills in its text +# * builds artifacts with cargo-dist (executable-zips, installers, hashes) # * uploads those artifacts to the Github Release™ +# * undrafts the Github Release™ on success # # Note that the Github Release™ will be created before the artifacts, # so there will be a few minutes where the release has no artifacts @@ -21,35 +22,39 @@ permissions: contents: write # This task will run whenever you push a git tag that looks like a version -# like "v1", "v1.2.0", "v0.1.0-prerelease01", "my-app-v1.0.0", etc. -# The version will be roughly parsed as ({PACKAGE_NAME}-)?v{VERSION}, where +# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. +# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where # PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION -# must be a Cargo-style SemVer Version. +# must be a Cargo-style SemVer Version (must have at least major.minor.patch). # -# If PACKAGE_NAME is specified, then we will create a Github Release™ for that +# If PACKAGE_NAME is specified, then the release will be for that # package (erroring out if it doesn't have the given version or isn't cargo-dist-able). # -# If PACKAGE_NAME isn't specified, then we will create a Github Release™ for all -# (cargo-dist-able) packages in the workspace with that version (this is mode is +# If PACKAGE_NAME isn't specified, then the release will be for all +# (cargo-dist-able) packages in the workspace with that version (this mode is # intended for workspaces with only one dist-able package, or with all dist-able # packages versioned/released in lockstep). # # If you push multiple tags at once, separate instances of this workflow will -# spin up, creating an independent Github Release™ for each one. +# spin up, creating an independent Github Release™ for each one. However Github +# will hard limit this to 3 tags per commit, as it will assume more tags is a +# mistake. # -# If there's a prerelease-style suffix to the version then the Github Release™ +# If there's a prerelease-style suffix to the version, then the Github Release™ # will be marked as a prerelease. on: push: tags: - - '*-?v[0-9]+*' + - '**[0-9]+.[0-9]+.[0-9]+*' jobs: - # Create the Github Release™ so the packages have something to be uploaded to - create-release: + # Run 'cargo dist plan' to determine what tasks we need to do + # and create a draft github release with the computed title/body + plan: runs-on: ubuntu-latest outputs: - has-releases: ${{ steps.create-release.outputs.has-releases }} + has-releases: ${{ steps.plan.outputs.has-releases }} + releases: ${{ steps.plan.outputs.releases }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: @@ -57,8 +62,8 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.1.0/cargo-dist-installer.sh | sh" - - id: create-release + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh" + - id: plan run: | cargo dist plan --tag=${{ github.ref_name }} --output-format=json > dist-manifest.json echo "dist plan ran successfully" @@ -78,33 +83,30 @@ jobs: # Disable all the upload-artifacts tasks if we have no actual releases HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json) echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT" + echo "releases=$(jq --compact-output ".releases" dist-manifest.json)" >> "$GITHUB_OUTPUT" - # Build and packages all the things - upload-artifacts: + # Build and packages all the platform-specific things + upload-local-artifacts: # Let the initial task tell us to not run (currently very blunt) - needs: create-release - if: ${{ needs.create-release.outputs.has-releases == 'true' }} + needs: plan + if: ${{ needs.plan.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.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" + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.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" + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.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" + install-dist: "irm https://github.com/axodotdev/cargo-dist/releases/download/v0.2.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" - + install-dist: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh" runs-on: ${{ matrix.os }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -132,11 +134,40 @@ jobs: gh release upload ${{ github.ref_name }} $(cat uploads.txt) echo "uploaded!" + # Build and package all the platform-agnostic(ish) things + upload-global-artifacts: + needs: upload-local-artifacts + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.2.0/cargo-dist-installer.sh | sh" + # Get all the local artifacts for the global tasks to use (for e.g. checksums) + - name: Fetch local artifacts + run: | + gh release download ${{ github.ref_name }} --dir target/distrib/ + - name: Run cargo-dist + run: | + cargo dist build --tag=${{ github.ref_name }} --output-format=json "--artifacts=global" > dist-manifest.json + echo "dist ran successfully" + cat dist-manifest.json + + # Parse out what we just built and upload it to the Github Release™ + 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) + echo "uploaded!" + # Mark the Github Release™ as a non-draft now that everything has succeeded! publish-release: # Only run after all the other tasks, but it's ok if upload-artifacts was skipped - needs: [create-release, upload-artifacts] - if: ${{ always() && needs.create-release.result == 'success' && (needs.upload-artifacts.result == 'skipped' || needs.upload-artifacts.result == 'success') }} + needs: [plan, upload-local-artifacts, upload-global-artifacts] + if: ${{ always() && needs.plan.result == 'success' && (needs.upload-local-artifacts.result == 'skipped' || needs.upload-local-artifacts.result == 'success') && (needs.upload-global-artifacts.result == 'skipped' || needs.upload-global-artifacts.result == 'success') }} runs-on: ubuntu-latest env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index 64a9120e94..359501dc67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ default-members = [ # Config for 'cargo dist' [workspace.metadata.dist] # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.1.0" +cargo-dist-version = "0.2.0" # CI backends to support (see 'cargo dist generate-ci') ci = ["github"] # The installers to generate for each app