Skip to content

Commit

Permalink
ci: build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
hms5232 committed Jun 23, 2024
1 parent 09447a6 commit 97cc8cd
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Reusable build workflow

on:
workflow_call:
inputs:
version:
required: true
type: string
description: Used in filename.
target:
required: true
type: string
description: Toolchain which compile for.
os:
required: true
type: string
description: The runner os.
bin:
required: false
type: string
description: Built binary filename.
default: ufwlog
command:
required: false
type: string
description: The commands to run.
default: build
strip:
required: false
type: boolean
default: true
args:
required: false
type: string
description: Arguments to be passed to cross build.
default: "--locked --release"
upload-artifact:
required: false
type: boolean
description: Upload to artifact or not.
default: true
binary-mode:
required: false
type: string
description: The binary where in. Should be one of "release" or "debug"
default: release

jobs:
build:

runs-on: ${{ inputs.os }}

name: ${{ inputs.bin }}
steps:
- uses: actions/checkout@v4
- name: Build
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ inputs.command }}
target: ${{ inputs.target }}
args: ${{ inputs.args }}
strip: true
- uses: actions/upload-artifact@v4
with:
# Name of the artifact to upload.
# Optional. Default is 'artifact'
name: ${{ inputs.bin }}_${{ inputs.version }}_${{ inputs.target }}

# A file, directory or wildcard pattern that describes what to upload
# Required.
path: target/${{ inputs.target }}/${{ inputs.binary-mode }}/${{ inputs.bin }}
35 changes: 35 additions & 0 deletions .github/workflows/debug_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Debug build

on:
pull_request:
branches: [ "main" ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
bin: ufwlog
command: build
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
bin: ufwlog
command: build
name: ${{ matrix.platform.target }}
uses: ./.github/workflows/build.yml
with:
version: ${{ github.sha }}
os: ${{ matrix.platform.os }}
binary-mode: debug
command: ${{ matrix.platform.command }}
bin: ${{ matrix.platform.bin }}
target: ${{ matrix.platform.target }}
args: "--locked"
strip: true
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
workflow_dispatch:
release:
types: [ published ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
bin: ufwlog
command: build
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
bin: ufwlog
command: build
name: Build/${{ matrix.platform.target }}
uses: ./.github/workflows/build.yml
with:
version: ${{ github.ref_name }}
os: ${{ matrix.platform.os }}
command: ${{ matrix.platform.command }}
bin: ${{ matrix.platform.bin }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: true

upload:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform:
- release_for: x86_64-unknown-linux-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: ufwlog
command: build
- release_for: aarch64-unknown-linux-gnu
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
bin: ufwlog
command: build

runs-on: ${{ matrix.platform.os }}

name: Upload/${{ matrix.platform.target }}
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.platform.bin }}_${{ github.ref_name }}_${{ matrix.platform.target }}
- name: Rename binary
run: mv ${{ matrix.platform.bin }} ${{ matrix.platform.bin }}_${{ github.ref_name }}_${{ matrix.platform.target }}
- name: Upload binary
uses: softprops/action-gh-release@v1
with:
files: ${{ matrix.platform.bin }}_${{ github.ref_name }}_${{ matrix.platform.target }}

0 comments on commit 97cc8cd

Please sign in to comment.