Skip to content

Commit

Permalink
ci: support musl target
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Sep 13, 2023
1 parent 2226f9d commit 5303ae0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/actions/replace-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ runs:
- name: Replace version
shell: bash
# There isn't a sed command working on all platforms to replace string in a file, so use perl.
run: perl -i -pe's/0.0.0-staging/${{ inputs.version }}/' Cargo.toml
run: perl -i -pe's/0.0.0-dev/${{ inputs.version }}/' Cargo.toml
13 changes: 6 additions & 7 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ jobs:
# aarch64
- { os: macos-11 , target: aarch64-apple-darwin , alias: aarch64-darwin-macos-11 }
- { os: macos-12 , target: aarch64-apple-darwin , alias: aarch64-darwin-macos-12 }
- { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu, alias: aarch64-gnu-ubuntu-20.04 }
- { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu, alias: aarch64-gnu-ubuntu-22.04 }
# amd64
- { os: macos-12 , target: x86_64-apple-darwin , alias: amd64-darwin-macos-unknown }
- { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu , alias: amd64-gnu-ubuntu-20.04 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu , alias: amd64-gnu-ubuntu-22.04 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-musl, alias: amd64-musl-linux-unknown }
- { os: windows-2019, target: x86_64-pc-windows-msvc , alias: amd64-msvc-windows-2019 }
- { os: windows-2022, target: x86_64-pc-windows-msvc , alias: amd64-msvc-windows-2022 }

Expand All @@ -38,15 +37,15 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup rust toolchain
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
toolchain: nightly-2023-09-06
components: rustfmt, clippy

- name: Show rust toolchain version
- name: Show Rust toolchain version
shell: bash
run: |
cargo -V
Expand All @@ -55,16 +54,16 @@ jobs:
rustc -V
- name: Setup musl-tools
if: runner.os == 'Linux'
if: matrix.targets.target == 'x86_64-unknown-linux-musl'
shell: bash
run: sudo apt install musl-tools
run: sudo apt -y install musl-tools

- name: Add target
uses: ./.github/actions/add-target
with:
target: ${{ matrix.targets.target }}

- name: Setup rust cache
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ matrix.targets.alias }}
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ jobs:
# aarch64
- { os: macos-11 , target: aarch64-apple-darwin , alias: aarch64-darwin-macos-11 }
- { os: macos-12 , target: aarch64-apple-darwin , alias: aarch64-darwin-macos-12 }
- { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu, alias: aarch64-gnu-ubuntu-20.04 }
- { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu, alias: aarch64-gnu-ubuntu-22.04 }
# amd64
- { os: macos-12 , target: x86_64-apple-darwin , alias: amd64-darwin-macos-unknown }
- { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu , alias: amd64-gnu-ubuntu-20.04 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu , alias: amd64-gnu-ubuntu-22.04 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-musl, alias: amd64-musl-linux-unknown }
- { os: windows-2019, target: x86_64-pc-windows-msvc , alias: amd64-msvc-windows-2019 }
- { os: windows-2022, target: x86_64-pc-windows-msvc , alias: amd64-msvc-windows-2022 }

Expand All @@ -32,7 +31,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup rust toolchain
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand All @@ -41,16 +40,16 @@ jobs:
components: rustfmt, clippy

- name: Setup musl-tools
if: runner.os == 'Linux'
if: matrix.targets.target == 'x86_64-unknown-linux-musl'
shell: bash
run: sudo apt install musl-tools
run: sudo apt -y install musl-tools

- name: Add target
uses: ./.github/actions/add-target
with:
target: ${{ matrix.targets.target }}

- name: Setup rust cache
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ matrix.targets.alias }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cnb"
# WRN: Version will be updated by CI while create a tag, NERVER change this.
version = "0.0.0-staging"
version = "0.0.0-dev"
edition = "2021"
description = "Cnblogs' command line tool"
license = "MIT"
Expand Down

0 comments on commit 5303ae0

Please sign in to comment.