From 3d3524b77d443852d0b0ae89a059a1c99dc808ed Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:59:34 +0100 Subject: [PATCH 1/8] fix: Improve action job name --- template/.github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index e5f6245..885d3f4 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -8,7 +8,7 @@ on: jobs: {% if crate_type == "bin" %} publish: - name: Publishing for {{ "${{ matrix.job.os }}" }} + name: Publishing for {{ "${{ matrix.job.os-name }}" }}-{{ "${{ matrix.job.architecture }}" }} runs-on: {{ "${{ matrix.job.os }}" }} permissions: contents: write From 715129f9fd5d724cc11c26bfd719f893780b9201 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:59:58 +0100 Subject: [PATCH 2/8] feat: Update matrix fail behaviour --- template/.github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index 885d3f4..24687d4 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -13,6 +13,7 @@ jobs: permissions: contents: write strategy: + fail-fast: false matrix: rust: [stable] job: From cb59dba410ecb43c5bcf367e327b465ce1945fa4 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:02:26 +0100 Subject: [PATCH 3/8] fix: Replace deprecated toolchain action --- template/.github/workflows/cd.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index 24687d4..185bc0e 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -58,12 +58,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@v1 with: toolchain: {{ "${{ matrix.rust }}" }} target: {{ "${{ matrix.job.target }}" }} - profile: minimal - override: true - uses: Swatinem/rust-cache@v2 - name: Cargo build uses: actions-rs/cargo@v1 From 5046c9226233ffaae2252dc54385a7de40cbb6e3 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:03:07 +0100 Subject: [PATCH 4/8] fix: Simplify conditional syntax --- template/.github/workflows/cd.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index 185bc0e..fed2ff1 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -72,12 +72,11 @@ jobs: args: --release --target {{ "${{ matrix.job.target }}" }} - name: install strip command + if: matrix.job.target == 'aarch64-unknown-linux-gnu' shell: bash run: | - if [[ {{ "${{ matrix.job.target }}" }} == aarch64-unknown-linux-gnu ]]; then - sudo apt update - sudo apt-get install -y binutils-aarch64-linux-gnu - fi + sudo apt update + sudo apt-get install -y binutils-aarch64-linux-gnu - name: Packaging final binary shell: bash run: | From 2830d0bd1469792b9c433307ba82891d611af8d5 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:28:06 +0100 Subject: [PATCH 5/8] feat(cd): Improve asset upload --- template/.github/workflows/cd.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index fed2ff1..a324da1 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -80,33 +80,34 @@ jobs: - name: Packaging final binary shell: bash run: | - cd target/{{ "${{ matrix.job.target }}" }}/release + BINARY=target/{{ "${{ matrix.job.target }}" }}/release/{{project-name}} + if [[ {{ "${{ matrix.job.os }}" }} == windows-latest ]]; then + BINARY=$BINARY.exe + fi ####### reduce binary size by removing debug symbols ####### - BINARY_NAME={{project-name}}{{ "${{ matrix.job.binary-postfix }}" }} if [[ {{ "${{ matrix.job.target }}" }} == aarch64-unknown-linux-gnu ]]; then GCC_PREFIX="aarch64-linux-gnu-" else GCC_PREFIX="" fi - "$GCC_PREFIX"strip $BINARY_NAME + "$GCC_PREFIX"strip $BINARY ########## create tar.gz ########## + mkdir assets RELEASE_NAME={{project-name}}-${GITHUB_REF/refs\/tags\//}-{{ "${{ matrix.job.os-name }}" }}-{{ "${{ matrix.job.architecture }}" }} - tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME + tar czvf assets/$RELEASE_NAME.tar.gz $BINARY ########## create sha256 ########## if [[ {{ "${{ runner.os }}" }} == 'Windows' ]]; then - certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256 + certutil -hashfile assets/$RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > assets/$RELEASE_NAME.sha256 else - shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256 + shasum -a 256 assets/$RELEASE_NAME.tar.gz > assets/$RELEASE_NAME.sha256 fi - name: Releasing assets uses: softprops/action-gh-release@v2 with: - files: | - target/{{ "${{ matrix.job.target }}" }}/release/{{project-name}}-*.tar.gz - target/{{ "${{ matrix.job.target }}" }}/release/{{project-name}}-*.sha256 + files: assets/* env: GITHUB_TOKEN: {{ "${{ secrets.GITHUB_TOKEN }}" }} {% endif %} From 486cee31e7b7c2b2aaacd5e3c2c2cc2dfb1c5722 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:29:02 +0100 Subject: [PATCH 6/8] fix(cd): Replace deprecated cargo action --- template/.github/workflows/cd.yml | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index a324da1..ef05fb2 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -21,38 +21,26 @@ jobs: os-name: macos target: x86_64-apple-darwin architecture: x86_64 - binary-postfix: "" - use-cross: false - os: macos-latest os-name: macos target: aarch64-apple-darwin architecture: arm64 - binary-postfix: "" - use-cross: false - os: ubuntu-latest os-name: linux target: x86_64-unknown-linux-gnu architecture: x86_64 - binary-postfix: "" - use-cross: false - os: windows-latest os-name: windows target: x86_64-pc-windows-msvc architecture: x86_64 - binary-postfix: ".exe" - use-cross: false - os: ubuntu-latest os-name: linux target: aarch64-unknown-linux-gnu architecture: arm64 - binary-postfix: "" - use-cross: true - os: ubuntu-latest os-name: linux target: i686-unknown-linux-gnu architecture: i686 - binary-postfix: "" - use-cross: true steps: - name: Checkout repository @@ -62,14 +50,12 @@ jobs: with: toolchain: {{ "${{ matrix.rust }}" }} target: {{ "${{ matrix.job.target }}" }} - - uses: Swatinem/rust-cache@v2 - - name: Cargo build - uses: actions-rs/cargo@v1 + - name: Install cross + uses: taiki-e/install-action@v2 with: - command: build - use-cross: {{ "${{ matrix.job.use-cross }}" }} - toolchain: {{ "${{ matrix.rust }}" }} - args: --release --target {{ "${{ matrix.job.target }}" }} + tool: cross + - name: Build release binary + run: cross build --locked --release --target {{ "${{ matrix.job.target }}" }} - name: install strip command if: matrix.job.target == 'aarch64-unknown-linux-gnu' From 0121a22352b3632c1f854f66d8dc2c84697a0170 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sun, 16 Mar 2025 12:46:53 +0100 Subject: [PATCH 7/8] Make action tag consistent Co-authored-by: Marco Ieni <11428655+marcoieni@users.noreply.github.com> --- template/.github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index ef05fb2..591a5f9 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -46,7 +46,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: toolchain: {{ "${{ matrix.rust }}" }} target: {{ "${{ matrix.job.target }}" }} From e51154bc869ad42d4b23051ba03d257827a1d634 Mon Sep 17 00:00:00 2001 From: PythonGermany <97847597+PythonGermany@users.noreply.github.com> Date: Sun, 16 Mar 2025 13:43:03 +0100 Subject: [PATCH 8/8] feat(cd): Use runner.os variable --- template/.github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/.github/workflows/cd.yml b/template/.github/workflows/cd.yml index 591a5f9..85ecbc0 100644 --- a/template/.github/workflows/cd.yml +++ b/template/.github/workflows/cd.yml @@ -67,7 +67,7 @@ jobs: shell: bash run: | BINARY=target/{{ "${{ matrix.job.target }}" }}/release/{{project-name}} - if [[ {{ "${{ matrix.job.os }}" }} == windows-latest ]]; then + if [[ {{ "${{ runner.os }}" }} == 'Windows' ]]; then BINARY=$BINARY.exe fi