Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up CI #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 1 addition & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
toolchain: "x86_64-unknown-linux-gnu"
name: "Linux GNU"
- os: "macOS-latest"
toolchain: "x86_64-apple-darwin"
toolchain: "aarch64-apple-darwin"
name: "macOS"
- os: "windows-latest"
toolchain: "x86_64-pc-windows-msvc"
Expand All @@ -63,38 +63,6 @@ jobs:
- name: cargo test
run: cargo test --locked --workspace --all-features --bins --tests --examples

test-release:
runs-on: ${{ matrix.target.os }}
strategy:
fail-fast: false
matrix:
target:
- os: "ubuntu-latest"
toolchain: "x86_64-unknown-linux-gnu"
name: "Linux GNU"
- os: "macOS-latest"
toolchain: "x86_64-apple-darwin"
name: "macOS"
- os: "windows-latest"
toolchain: "x86_64-pc-windows-msvc"
name: "Windows MSVC"
- os: "windows-latest"
toolchain: "x86_64-pc-windows-gnu"
name: "Windows GNU"
channel:
- "stable"
- "beta"
- "nightly"
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.channel }}
targets: ${{ matrix.target.toolchain }}
- uses: swatinem/rust-cache@v2
- name: cargo test
run: cargo test --release --locked --workspace --all-features --bins --tests --examples

# Checks correct runtime deps and features are requested by not including dev-dependencies.
check-deps:
runs-on: ubuntu-latest
Expand All @@ -104,16 +72,3 @@ jobs:
- uses: swatinem/rust-cache@v2
- name: cargo check
run: cargo check --workspace --all-features --bins

# Minimal crates needs adding proc-macro 1.0.66 as a dev dependency.
# Since it is not necessary for a bin project, disabled.
# minimal-crates:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: dtolnay/rust-toolchain@nightly
# - uses: swatinem/rust-cache@v2
# - name: cargo check
# run: |
# rm -f Cargo.lock
# cargo +nightly check -Z minimal-versions --workspace --all-features --bins
52 changes: 44 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release_version:
description: "Release version"
required: true
default: ""
create_release:
description: "Create release"
required: true
default: "true"
upload_artifacts:
description: "Upload artifacts"
required: true
default: "true"

env:
BIN_NAME: dumbpipe
Expand All @@ -32,19 +46,26 @@ jobs:
upload_url: ${{ steps.release.outputs.upload_url }}
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Get the release version from the tag
- name: Get the release version from the tag (push)
shell: bash
if: env.RELEASE_VERSION == ''
if: env.RELEASE_VERSION == '' && github.event_name == 'push'
run: |
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
- name: Get the release version from the tag (dispatch)
shell: bash
if: github.event_name == 'workflow_dispatch'
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Create GitHub release
id: release
if: github.event.inputs.create_release == 'true' || github.event_name == 'push'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -57,29 +78,34 @@ jobs:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
name: [ubuntu-latest, ubuntu-arm-latest, macOS-latest, macOS-arm-latest, windows-latest]
name: [ubuntu-latest, ubuntu-arm-latest, macOS-arm-latest, macOS-latest, windows-latest]
rust: [stable]
include:
- name: ubuntu-arm-latest
os: ubuntu-latest
target: linux-aarch64
cargo_targets: "aarch64-unknown-linux-musl"
runner: [self-hosted, linux, ARM64]
- name: ubuntu-latest
os: ubuntu-latest
target: linux-x86_64
cargo_targets: "x86_64-unknown-linux-musl"
runner: [self-hosted, linux, X64]
- name: macOS-latest
os: macOS-latest
target: darwin-x86_64
runner: [self-hosted, macOS, X64]
cargo_targets: "x86_64-apple-darwin"
runner: [self-hosted, macOS, ARM64]
- name: macOS-arm-latest
os: macOS-latest
target: darwin-aarch64
cargo_targets: "aarch64-apple-darwin"
runner: [self-hosted, macOS, ARM64]
# TODO: windows runner is not available on the org level
- name: windows-latest
os: windows-latest
target: windows-x86_64
cargo_targets: "x86_64-pc-windows-msvc"
runner: [windows-latest]
steps:
- name: Checkout repository
Expand All @@ -90,26 +116,36 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.cargo_targets }}
- name: Ensure musl support
if: ${{ contains(matrix.cargo_targets, '-musl') }}
run: sudo apt-get install musl-tools -y
- name: Build release binary
run: cargo build --verbose --release
shell: bash
run: |
if [ "${{ matrix.name }}" = "ubuntu-arm-latest" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc
export CC=aarch64-linux-gnu-gcc
fi
cargo build --verbose --release --target ${{ matrix.cargo_targets }}
- name: Build archive
shell: bash
run: |
outdir="./target/release"
staging="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.release_version }}-${{ matrix.target }}"
mkdir -p "$staging"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "target/release/${{ env.BIN_NAME }}.exe" "$staging/"
cp "target/${{ matrix.cargo_targets }}/release/${{ env.BIN_NAME }}.exe" "$staging/"
cd "$staging"
7z a "../$staging.zip" .
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "target/release/${{ env.BIN_NAME }}" "$staging/"
cp "target/${{ matrix.cargo_targets }}/release/${{ env.BIN_NAME }}" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/[email protected]
if: github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
Loading