Skip to content

Commit

Permalink
ci: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
7sDream committed Nov 12, 2023
1 parent 056b0dd commit 91e1e6d
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 144 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: build
on:
workflow_call:
inputs:
name:
required: true
type: string
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
rust-target: x86_64-pc-windows-msvc
platform: win32
arch: x64
- os: windows-latest
rust-target: i686-pc-windows-msvc
platform: win32
arch: ia32
- os: windows-latest
rust-target: aarch64-pc-windows-msvc
platform: win32
arch: arm64
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
platform: linux
arch: x64
- os: ubuntu-20.04
rust-target: aarch64-unknown-linux-gnu
platform: linux
arch: arm64
- os: ubuntu-20.04
rust-target: arm-unknown-linux-gnueabihf
platform: linux
arch: armhf
- os: macos-11
rust-target: x86_64-apple-darwin
platform: darwin
arch: x64
- os: macos-11
rust-target: aarch64-apple-darwin
platform: darwin
arch: arm64
name: Build for ${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchains
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.rust-target }}
- name: Install AArch64 target toolchain
if: matrix.rust-target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
- name: Install ARM target toolchain
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Cache cargo registry and index
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: |
cargo clean
cargo build --release --all-targets --all-features -vv
- name: Upload build result
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.name }}-${{ matrix.platform }}-${{ matrix.arch }}
path: target/release/${{ inputs.name }}${{ fromJSON('[".exe", ""]')[matrix.platform == 'win32'] }}
65 changes: 16 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust toolchains
uses: actions-rs/toolchain@v1
uses: actions/checkout@v4

- name: Install Rust nightly toolchains
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: stable
override: true
components: rustfmt, clippy
components: rustfmt
- name: Check code style
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
args: +nightly --all -- --check

- name: Install Rust stable toolchains
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Lint code by clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings
args: --all-targets --all-features -- -D warnings'

build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install freetype and fontconfig for macOS
if: ${{ runner.os == 'macOS' }}
run: |
brew install pkg-config cmake freetype fontconfig
pkg-config --libs --static fontconfig
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust toolchains
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Build
id: build
run: |
cargo clean
cargo build --all-targets --all-features --jobs 1 -vv || echo "::set-output name=fail::1"
- name: Upload build result to artifact
if: steps.build.outputs.fail == '1'
uses: actions/upload-artifact@v2
with:
name: target-${{ runner.OS }}
path: target/
- name: Fail after upload build result
if: steps.build.outputs.fail == '1'
run: "false"
uses: ./.github/workflows/build.yml
with:
name: fontfor
7 changes: 2 additions & 5 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-outdated
uses: actions-rs/[email protected]
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
if: "!github.event.release.draft && !github.event.release.prerelease"
if: ${{ !github.event.release.draft && !github.event.release.prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: refs/tags/${{ github.event.release.tag_name }}
- name: Install Rust toolchains
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and index
uses: actions/cache@v3
with:
toolchain: stable
override: true
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Publish crate
uses: actions-rs/cargo@v1
env:
Expand Down
92 changes: 16 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:

tag_check_deps_version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-outdated
uses: actions-rs/[email protected]
with:
Expand All @@ -36,36 +34,15 @@ jobs:
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
release_build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install freetype and fontconfig for macOS
if: ${{ runner.os == 'macOS' }}
run: |
brew install pkg-config cmake freetype fontconfig
pkg-config --libs --static fontconfig
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build use release profile
run: cargo build --all-targets --all-features -vv --release
- name: Upload release binary to artifact
uses: actions/upload-artifact@v2
with:
name: release-${{ runner.os }}
path: target/release/fontfor

build:
uses: ./.github/workflows/build.yml
with:
name: fontfor

create_release:
needs: [tag_check_deps_version, release_build]
needs: [tag_check_deps_version, build]
runs-on: ubuntu-latest
outputs:
release_upload_url: ${{ steps.release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -80,50 +57,13 @@ jobs:
message="${message//$'\n'/'%0A'}"
message="${message//$'\r'/'%0D'}"
echo "::set-output name=message::$message"
- name: Create release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.release_token }}
- name: Download Linux binary from artifact
uses: actions/download-artifact@v3
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.tag.outputs.name }}
token: ${{ secrets.release_token }}
body: ${{ steps.tag.outputs.message }}
draft: false
prerelease: false
upload_binary:
needs: [create_release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download Linux binary from artifact
uses: actions/download-artifact@v2
with:
name: release-Linux
path: artifacts/release-Linux
- name: Download macOS binary from artifact
uses: actions/download-artifact@v2
with:
name: release-macOS
path: artifacts/release-macOS
- name: Show artifacts content
run: ls -a -l -R artifacts
- name: Upload Linux binary asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_upload_url }}
asset_path: ./artifacts/release-Linux/fontfor
asset_name: fontfor-Linux
asset_content_type: application/octet-stream
- name: Upload macOS binary asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_upload_url }}
asset_path: ./artifacts/release-macOS/fontfor
asset_name: fontfor-macOS
asset_content_type: application/octet-stream
files: fontfor-*/fontfor*

0 comments on commit 91e1e6d

Please sign in to comment.