From b726d9d06e243aa078418737064026b3f4b64991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Wed, 18 Oct 2023 17:23:09 +0200 Subject: [PATCH] Bump Former-commit-id: eaebbb9e25ac2e8dcb8dba0d33fe6fe428aac7d3 [formerly 5547180d1b421cc08175ec8065a046c4d53b1161] [formerly a1cd88c86598dfda4f58d8af13bd407824d3bf16 [formerly fa94dec2b8b223f00a545270b2caf61d28e695be]] Former-commit-id: 9eef7969e5a19c20ded9071cfdca683da786c295 [formerly 02aad0e476ab26411999fd996833b830d098099c] Former-commit-id: 1d9dc945ecaea483ba89cee516982da76f4d70ea Former-commit-id: 1b0c2d92fd4136bb2071f14d105ba5f4a222cf13 Former-commit-id: 6ef7e1fd9f541587791367b3d5109e3b79c351f6 Former-commit-id: afd882eea1240d95fe1c426f5ffd8ba09ff076c0 [formerly 2648785ac1bc295b39956f9268bc8da604dfa841] Former-commit-id: f0982b47b29a2b5a1c240607e5a53efb6c73a3aa --- .github/workflows/release.yaml | 259 +++++++++++++++++---------------- .github/workflows/release.yml | 155 -------------------- 2 files changed, 131 insertions(+), 283 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 356c268..94c32b8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,128 +1,131 @@ -#on: -# # Indicates I want to run this workflow on all branches, PR, and tags -# push: -# branches: ["neo"] -# tags: ["*"] -# pull_request: -# branches: [ "main" ] -# -#env: -# RUST_VERSION: 1.73.0 -# BUILD_ARGS: "--release" -# BIN_NAME: "wstunnel" -# -#jobs: -# build: -# name: Build - ${{ matrix.platform.name }} -# # By default, runs on Ubuntu, otherwise, override with the desired os -# runs-on: ${{ matrix.platform.os || 'ubuntu-22.04' }} -# strategy: -# matrix: -# # Set platforms you want to build your binaries on -# platform: -# # Linux -# - name: Linux x86_64 -# target: x86_64-unknown-linux-musl -# -# - name: Linux aarch64 -# target: aarch64-unknown-linux-musl -# -# - name: Linux armv7hf -# target: armv7-unknown-linux-musleabihf -# -# #- name: Linux mips -# # target: mips-unknown-linux-musl -# -# #- name: Linux mips64 -# # target: mips64-unknown-linux-muslabi64 -# -# # Mac OS -# - name: MacOS x86_64 -# target: x86_64-apple-darwin -# -# # - name: iOS x86_64 -# # target: x86_64-apple-ios -# -# #- name: MacOS aarch64 -# # target: aarch64-apple-darwin -# -# #- name: iOS aarch64 -# # target: aarch64-apple-ios -# -# -# # Windows -# - name: Windows x86_64 -# os: windows-latest -# target: x86_64-pc-windows-msvc -# -# steps: -# - name: Create annotation for build error -# if: contains(matrix.platform.target, 'linux') -# run: sudo apt install musl-tools -# -# - name: Checkout Git repo -# uses: actions/checkout@v3 -# -# # Linux & Windows -# - name: Install rust toolchain -# if: ${{ !contains(matrix.platform.target, 'apple') }} -# uses: actions-rs/toolchain@v1 -# with: -# # We setup Rust toolchain and the desired target -# profile: minimal -# toolchain: "${{ env.RUST_VERSION }}" -# override: true -# target: ${{ matrix.platform.target }} -# components: rustfmt, clippy -# - name: Build ${{ matrix.platform.name }} binary -# if: ${{ !contains(matrix.platform.target, 'apple') }} -# uses: actions-rs/cargo@v1 -# # We use cross-rs if not running on x86_64 architecture on Linux -# with: -# command: build -# use-cross: ${{ !contains(matrix.platform.target, 'x86_64') }} -# args: ${{ env.BUILD_ARGS }} --target ${{ matrix.platform.target }} -# -# # Mac OS -# - name: Build ${{ matrix.platform.name }} binary -# if: contains(matrix.platform.target, 'apple') -# # We use a dedicated Rust image containing required Apple libraries to cross-compile on multiple archs -# run: | -# docker run --rm --volume "${PWD}":/root/src --workdir /root/src joseluisq/rust-linux-darwin-builder:$RUST_VERSION \ -# sh -c "CC=o64-clang CXX=o64-clang++ cargo build $BUILD_ARGS --target ${{ matrix.platform.target }}" -# -# - name: Store artifact -# uses: actions/upload-artifact@v3 -# with: -# # Finally, we store the binary as GitHub artifact for later usage -# name: ${{ matrix.platform.target }}-${{ env.BIN_NAME }} -# path: target/${{ matrix.platform.target }}/release/${{ env.BIN_NAME }}${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }} -# retention-days: 1 -# -# release: -# name: Release -# needs: [build] -# # We run the release job only if a tag starts with 'v' letter -# if: startsWith( github.ref, 'refs/tags/v' ) -# runs-on: ubuntu-22.04 -# steps: -# - name: Checkout Git repo -# uses: actions/checkout@v3 -# -# # Download all artifacts -# - uses: actions/download-artifact@v3 -# with: -# path: artifacts -# -# # Goreleaser -# - name: Set up Go -# uses: actions/setup-go@v4 -# - name: Run GoReleaser -# uses: goreleaser/goreleaser-action@v5 -# with: -# distribution: goreleaser -# version: latest -# # Run goreleaser and ignore non-committed files (downloaded artifacts) -# args: release --clean --skip=validate -# env: -# GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} +on: + # Indicates I want to run this workflow on all branches, PR, and tags + push: + branches: ["neo"] + tags: ["*"] + pull_request: + branches: [ "main" ] + +env: + RUST_VERSION: 1.73.0 + BUILD_ARGS: "--release" + BIN_NAME: "wstunnel" + +jobs: + build: + name: Build - ${{ matrix.platform.name }} + # By default, runs on Ubuntu, otherwise, override with the desired os + runs-on: ${{ matrix.platform.os || 'ubuntu-22.04' }} + strategy: + matrix: + # Set platforms you want to build your binaries on + platform: + # Linux + - name: Linux x86_64 + target: x86_64-unknown-linux-musl + + - name: Linux aarch64 + target: aarch64-unknown-linux-musl + + - name: Linux armv7hf + target: armv7-unknown-linux-musleabihf + + #- name: Linux mips + # target: mips-unknown-linux-musl + + #- name: Linux mips64 + # target: mips64-unknown-linux-muslabi64 + + # Mac OS + - name: MacOS x86_64 + target: x86_64-apple-darwin + + # - name: iOS x86_64 + # target: x86_64-apple-ios + + #- name: MacOS aarch64 + # target: aarch64-apple-darwin + + #- name: iOS aarch64 + # target: aarch64-apple-ios + + + # Windows + - name: Windows x86_64 + os: windows-latest + target: x86_64-pc-windows-msvc + + steps: + - name: Create annotation for build error + if: contains(matrix.platform.target, 'linux') + run: sudo apt install musl-tools + + - name: Checkout Git repo + uses: actions/checkout@v3 + + # Linux & Windows + - name: Install rust toolchain + if: ${{ !contains(matrix.platform.target, 'apple') }} + uses: actions-rs/toolchain@v1 + with: + # We setup Rust toolchain and the desired target + profile: minimal + toolchain: "${{ env.RUST_VERSION }}" + override: true + target: ${{ matrix.platform.target }} + components: rustfmt, clippy + - name: Build ${{ matrix.platform.name }} binary + if: ${{ !contains(matrix.platform.target, 'apple') }} + uses: actions-rs/cargo@v1 + # We use cross-rs if not running on x86_64 architecture on Linux + with: + command: build + use-cross: ${{ !contains(matrix.platform.target, 'x86_64') }} + args: ${{ env.BUILD_ARGS }} --target ${{ matrix.platform.target }} + + # Mac OS + - name: Build ${{ matrix.platform.name }} binary + if: contains(matrix.platform.target, 'apple') + # We use a dedicated Rust image containing required Apple libraries to cross-compile on multiple archs + run: | + docker run --rm --volume "${PWD}":/root/src --workdir /root/src joseluisq/rust-linux-darwin-builder:$RUST_VERSION \ + sh -c "CC=o64-clang CXX=o64-clang++ cargo build $BUILD_ARGS --target ${{ matrix.platform.target }}" + + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + # Finally, we store the binary as GitHub artifact for later usage + name: ${{ matrix.platform.target }}-${{ env.BIN_NAME }} + path: target/${{ matrix.platform.target }}/release/${{ env.BIN_NAME }}${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }} + retention-days: 1 + + release: + name: Release + needs: [build] + # We run the release job only if a tag starts with 'v' letter + if: startsWith( github.ref, 'refs/tags/v' ) + runs-on: ubuntu-22.04 + steps: + - name: Checkout Git repo + uses: actions/checkout@v3 + + # Download all artifacts + - uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: list artifacts + run: ls * ; ls artifacts/* + + # Goreleaser + - name: Set up Go + uses: actions/setup-go@v4 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + # Run goreleaser and ignore non-committed files (downloaded artifacts) + args: release --clean --skip=validate + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 56ed1f7..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright 2022-2023, axodotdev -# SPDX-License-Identifier: MIT or Apache-2.0 -# -# CI that: -# -# * checks for a Git Tag that looks like a release -# * builds artifacts with cargo-dist (archives, installers, hashes) -# * uploads those artifacts to temporary workflow zip -# * on success, uploads the artifacts to a Github Release™ -# -# Note that the Github Release™ will be created with a generated -# title/body based on your changelogs. -name: Release - -permissions: - contents: write - -# This task will run whenever you push a git tag that looks like a version -# 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 have at least major.minor.patch). -# -# 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 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. 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™ -# will be marked as a prerelease. -on: - push: - tags: - - '**[0-9]+.[0-9]+.[0-9]+*' - -jobs: - # Run 'cargo dist plan' to determine what tasks we need to do - plan: - runs-on: ubuntu-latest - outputs: - val: ${{ steps.plan.outputs.manifest }} - tag: ${{ !github.event.pull_request && github.ref_name || '' }} - tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} - publishing: ${{ !github.event.pull_request }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.3.1/cargo-dist-installer.sh | sh" - - id: plan - run: | - cargo dist plan ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} --output-format=json > dist-manifest.json - echo "cargo dist plan ran successfully" - cat dist-manifest.json - echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" - - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v3 - with: - name: artifacts - path: dist-manifest.json - - # Build and packages all the platform-specific things - upload-local-artifacts: - # Let the initial task tell us to not run (currently very blunt) - needs: plan - if: ${{ fromJson(needs.plan.outputs.val).releases != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} - strategy: - fail-fast: false - # Target platforms/runners are computed by cargo-dist in create-release. - # Each member of the matrix has the following arguments: - # - # - runner: the github runner - # - dist-args: cli flags to pass to cargo dist - # - install-dist: expression to run to install cargo-dist on the runner - # - # Typically there will be: - # - 1 "global" task that builds universal installers - # - N "local" tasks that build each platform's binaries and platform-specific installers - matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} - runs-on: ${{ matrix.runner }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: swatinem/rust-cache@v2 - - name: Install cargo-dist - run: ${{ matrix.install_dist }} - - name: Build artifacts - run: | - # Actually do builds and make zips and whatnot - cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json ${{ matrix.dist_args }} > dist-manifest.json - echo "cargo dist ran successfully" - - id: cargo-dist - name: Post-build - # We force bash here just because github makes it really hard to get values up - # to "real" actions without writing to env-vars, and writing to env-vars has - # inconsistent syntax between shell and powershell. - shell: bash - run: | - # Parse out what we just built and upload it to the Github Release™ - echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - - name: "Upload artifacts" - uses: actions/upload-artifact@v3 - with: - name: artifacts - path: ${{ steps.cargo-dist.outputs.paths }} - - should-publish: - needs: - - plan - - upload-local-artifacts - if: ${{ needs.plan.outputs.publishing == 'true' }} - runs-on: ubuntu-latest - steps: - - name: print tag - run: echo "ok we're publishing!" - - # Create a Github Release with all the results once everything is done, - publish-release: - needs: [plan, should-publish] - runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: "Download artifacts" - uses: actions/download-artifact@v3 - with: - name: artifacts - path: artifacts - - name: Create Release - uses: ncipollo/release-action@v1 - with: - tag: ${{ needs.plan.outputs.tag }} - name: ${{ fromJson(needs.plan.outputs.val).announcement_title }} - body: ${{ fromJson(needs.plan.outputs.val).announcement_github_body }} - prerelease: ${{ fromJson(needs.plan.outputs.val).announcement_is_prerelease }} - artifacts: "artifacts/*"