From cf6741e417e7029b1d284519a02dbd6b65b7b3c5 Mon Sep 17 00:00:00 2001 From: Todd Martin <33560895+martintc@users.noreply.github.com> Date: Sat, 23 Dec 2023 12:41:29 -0800 Subject: [PATCH] New release action (#380) --- .github/workflows/main.yaml | 99 +++++++++------- .../workflows/{main2.yaml => main.yaml.old} | 110 +++++++----------- 2 files changed, 104 insertions(+), 105 deletions(-) rename .github/workflows/{main2.yaml => main.yaml.old} (60%) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2e07fa84..06402559 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -67,57 +67,78 @@ jobs: CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} build: - name: build-${{ matrix.job.target }} - runs-on: ${{ matrix.job.os }} + name: Build-${{ matrix.platform.target }} + runs-on: ${{ matrix.platform.os }} strategy: fail-fast: false matrix: - job: - - { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu } - - { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu } - - - { os: macos-12, target: x86_64-apple-darwin } - - { os: macos-12, target: aarch64-apple-darwin } - - - { os: windows-2022, target: x86_64-pc-windows-msvc } + platform: + - os_name: Linux-x86_64-gnu + os: ubuntu-22.04 + target: x86_64-unknown-linux-gnu + bin: comtrya + name: comtrya-x86_64-unknown-linux-gnu + cross: false + cargo_command: cargo + skip_tests: false + - os_name: Linux-aarch64-gnu + os: ubuntu-22.04 + target: aarch64-unknown-linux-gnu + bin: comtrya + name: comtrya-aarch64-unknown-linux-gnu + cross: false + cargo_command: ./cross + skip_tests: false + - os_name: Windows-x86_64 + os: windows-2022 + target: x86_64-pc-windows-msvc + bin: comtrya.exe + name: comtrya-x86_64-pc-windows-msvc + cross: false + cargo_command: cargo + skip_tests: false + - os_name: macOS-x86_64 + os: macos-12 + target: x86_64-apple-darwin + bin: comtrya + name: comtrya-x86_64-apple-darwin + cross: false + cargo_command: cargo + skip_tests: false + - os_name: macOS-aarch64 + os: macos-12 + target: aarch64-apple-darwin + bin: comtrya + name: comtrya-aarch64-apple-darwin + cross: true + cargo_command: ./cross + skip_tests: false steps: - - name: Clone Repository + - name: Checkout uses: actions/checkout@v4 - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }} - target: ${{ matrix.job.target }} - override: true - default: true - profile: minimal - - - name: Handle Rust Dependencies Caching - uses: Swatinem/rust-cache@v2 + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0 with: - key: v1-${{ matrix.job.target }} - - - name: Build Release Binary - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - + command: "build" + target: ${{ matrix.platform.target }} + toolchain: stable + args: "--release" + - name: Rename Binary - if: matrix.job.target != 'x86_64-pc-windows-msvc' + if: matrix.platform.target != 'x86_64-pc-windows-msvc' shell: bash run: | - mv target/release/comtrya comtrya-${{ matrix.job.target }} + mv target/${{ matrix.platform.target }}/release/comtrya comtrya-${{ matrix.platform.target }} - name: Rename Binary.exe - if: matrix.job.target == 'x86_64-pc-windows-msvc' + if: matrix.platform.target == 'x86_64-pc-windows-msvc' shell: bash run: | - mv target/release/comtrya.exe comtrya-${{ matrix.job.target }}.exe + mv target/${{ matrix.platform.target }}/release/comtrya.exe comtrya-${{ matrix.platform.target }}.exe - name: Upload Artifact - if: matrix.job.target != 'x86_64-pc-windows-msvc' + if: matrix.platform.target != 'x86_64-pc-windows-msvc' uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -127,10 +148,10 @@ jobs: generate_release_notes: false fail_on_unmatched_files: true files: | - comtrya-${{ matrix.job.target }} + comtrya-${{ matrix.platform.target }} - name: Upload Artifact.exe - if: matrix.job.target == 'x86_64-pc-windows-msvc' + if: matrix.platform.target == 'x86_64-pc-windows-msvc' uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -140,7 +161,7 @@ jobs: generate_release_notes: false fail_on_unmatched_files: true files: | - comtrya-${{ matrix.job.target }}.exe + comtrya-${{ matrix.platform.target }}.exe build-musl: runs-on: ubuntu-latest @@ -180,4 +201,4 @@ jobs: generate_release_notes: false fail_on_unmatched_files: true files: | - target/x86_64-unknown-linux-musl/release/comtrya-x86_64-unknown-linux-musl + target/x86_64-unknown-linux-musl/release/comtrya-x86_64-unknown-linux-musl \ No newline at end of file diff --git a/.github/workflows/main2.yaml b/.github/workflows/main.yaml.old similarity index 60% rename from .github/workflows/main2.yaml rename to .github/workflows/main.yaml.old index 9f1075f3..2e07fa84 100644 --- a/.github/workflows/main2.yaml +++ b/.github/workflows/main.yaml.old @@ -1,11 +1,10 @@ -name: release-experimental +name: release on: - workflow_dispatch: - inputs: - environment: - description: 'Experiment with new workflow' - required: true + workflow_dispatch: {} + push: + branches: + - "main" env: MIN_SUPPORTED_RUST_VERSION: "1.70.0" @@ -68,78 +67,57 @@ jobs: CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} build: - name: Build-${{ matrix.platform.target }} - runs-on: ${{ matrix.platform.os }} + name: build-${{ matrix.job.target }} + runs-on: ${{ matrix.job.os }} strategy: fail-fast: false matrix: - platform: - - os_name: Linux-x86_64-gnu - os: ubuntu-22.04 - target: x86_64-unknown-linux-gnu - bin: comtrya - name: comtrya-x86_64-unknown-linux-gnu - cross: false - cargo_command: cargo - skip_tests: false - - os_name: Linux-aarch64-gnu - os: ubuntu-22.04 - target: aarch64-unknown-linux-gnu - bin: comtrya - name: comtrya-aarch64-unknown-linux-gnu - cross: false - cargo_command: ./cross - skip_tests: true - - os_name: Windows-x86_64 - os: windows-2022 - target: x86_64-pc-windows-msvc - bin: comtrya.exe - name: comtrya-x86_64-pc-windows-msvc - cross: false - cargo_command: cargo - skip_tests: false - - os_name: macOS-x86_64 - os: macos-12 - target: x86_64-apple-darwin - bin: comtrya - name: comtrya-x86_64-apple-darwin - cross: false - cargo_command: cargo - skip_tests: false - - os_name: macOS-aarch64 - os: macos-12 - target: aarch64-apple-darwin - bin: comtrya - name: comtrya-aarch64-apple-darwin - cross: true - cargo_command: ./cross - skip_tests: true + job: + - { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu } + - { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu } + + - { os: macos-12, target: x86_64-apple-darwin } + - { os: macos-12, target: aarch64-apple-darwin } + + - { os: windows-2022, target: x86_64-pc-windows-msvc } steps: - - name: Checkout + - name: Clone Repository uses: actions/checkout@v4 - - name: Build binary - uses: houseabsolute/actions-rust-cross@v0 + - name: Install Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }} + target: ${{ matrix.job.target }} + override: true + default: true + profile: minimal + + - name: Handle Rust Dependencies Caching + uses: Swatinem/rust-cache@v2 with: - command: "build" - target: ${{ matrix.platform.target }} - toolchain: stable - args: "--release" - + key: v1-${{ matrix.job.target }} + + - name: Build Release Binary + uses: actions-rs/cargo@v1 + with: + command: build + args: --release + - name: Rename Binary - if: matrix.platform.target != 'x86_64-pc-windows-msvc' + if: matrix.job.target != 'x86_64-pc-windows-msvc' shell: bash run: | - mv target/${{ matrix.platform.target }}/release/comtrya comtrya-${{ matrix.platform.target }} + mv target/release/comtrya comtrya-${{ matrix.job.target }} - name: Rename Binary.exe - if: matrix.platform.target == 'x86_64-pc-windows-msvc' + if: matrix.job.target == 'x86_64-pc-windows-msvc' shell: bash run: | - mv target/${{ matrix.platform.target }}/release/comtrya.exe comtrya-${{ matrix.platform.target }}.exe + mv target/release/comtrya.exe comtrya-${{ matrix.job.target }}.exe - name: Upload Artifact - if: matrix.platform.target != 'x86_64-pc-windows-msvc' + if: matrix.job.target != 'x86_64-pc-windows-msvc' uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -149,10 +127,10 @@ jobs: generate_release_notes: false fail_on_unmatched_files: true files: | - comtrya-${{ matrix.platform.target }} + comtrya-${{ matrix.job.target }} - name: Upload Artifact.exe - if: matrix.platform.target == 'x86_64-pc-windows-msvc' + if: matrix.job.target == 'x86_64-pc-windows-msvc' uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -162,7 +140,7 @@ jobs: generate_release_notes: false fail_on_unmatched_files: true files: | - comtrya-${{ matrix.platform.target }}.exe + comtrya-${{ matrix.job.target }}.exe build-musl: runs-on: ubuntu-latest @@ -202,4 +180,4 @@ jobs: generate_release_notes: false fail_on_unmatched_files: true files: | - target/x86_64-unknown-linux-musl/release/comtrya-x86_64-unknown-linux-musl \ No newline at end of file + target/x86_64-unknown-linux-musl/release/comtrya-x86_64-unknown-linux-musl