Skip to content

Commit

Permalink
New release action (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
martintc committed Dec 23, 2023
1 parent 6b5dc0d commit cf6741e
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 105 deletions.
99 changes: 60 additions & 39 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
110 changes: 44 additions & 66 deletions .github/workflows/main2.yaml → .github/workflows/main.yaml.old
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
target/x86_64-unknown-linux-musl/release/comtrya-x86_64-unknown-linux-musl

0 comments on commit cf6741e

Please sign in to comment.