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

Update CI/CD and add universal macOS binary #127

Merged
merged 2 commits into from
Oct 16, 2023
Merged
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
73 changes: 30 additions & 43 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,93 +15,80 @@ jobs:
upload_url: ${{ steps.step.outputs.upload_url }}

steps:
- uses: actions/create-release@v1
- uses: softprops/action-gh-release@v1
id: step
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
name: ${{ github.ref }}
draft: false

build_release:
name: Build release
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
targets: [x86_64-unknown-linux-gnu]
suffix: linux-x86_64.tar.gz
- os: macos-latest
targets: [x86_64-apple-darwin, aarch64-apple-darwin]
suffix: mac-universal.tar.gz
- os: windows-latest
targets: [x86_64-pc-windows-msvc]
suffix: windows-x86_64.zip
runs-on: ${{ matrix.os }}
needs: create_release

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ join(matrix.targets, ',') }}

- name: Build
run: cargo build --release

- name: Create artifact directory
run: mkdir artifacts
run: |
for target in ${{ join(matrix.targets, ' ') }}; do
cargo build --release --target $target
done

- name: Create Linux archive
run: tar -czvf ./artifacts/${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz ./target/release/${{ env.RELEASE_BIN }}
if: matrix.os == 'ubuntu-latest'

- name: Upload Linux archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz
asset_name: ${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz
asset_content_type: application/gzip
run: tar -czvf ./${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz ./target/x86_64-unknown-linux-gnu/release/${{ env.RELEASE_BIN }}
if: matrix.os == 'ubuntu-latest'

- name: Create Windows archive
run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-windows-x86_64.zip ./target/release/${{ env.RELEASE_BIN }}.exe
if: matrix.os == 'windows-latest'

- name: Upload Windows archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.RELEASE_BIN }}-windows-x86_64.zip
asset_name: ${{ env.RELEASE_BIN }}-windows-x86_64.zip
asset_content_type: application/zip
run: 7z a -tzip ./${{ env.RELEASE_BIN }}-windows-x86_64.zip ./target/x86_64-pc-windows-msvc/release/${{ env.RELEASE_BIN }}.exe
if: matrix.os == 'windows-latest'

- name: Create macOS archive
run: tar -czvf ./artifacts/${{ env.RELEASE_BIN }}-mac-x86_64.tar.gz ./target/release/${{ env.RELEASE_BIN }}
run:
lipo -create -output ./${{ env.RELEASE_BIN }}-mac-universal ./target/x86_64-apple-darwin/release/${{ env.RELEASE_BIN }} ./target/aarch64-apple-darwin/release/${{ env.RELEASE_BIN }}
tar -czvf ./${{ env.RELEASE_BIN }}-mac-universal.tar.gz ./${{ env.RELEASE_BIN }}-mac-universal
if: matrix.os == 'macos-latest'

- name: Upload macOS archive
uses: actions/upload-release-asset@v1
- name: Upload archive
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./artifacts/${{ env.RELEASE_BIN }}-mac-x86_64.tar.gz
asset_name: ${{ env.RELEASE_BIN }}-mac-x86_64.tar.gz
asset_content_type: application/gzip
if: matrix.os == 'macos-latest'
asset_path: ./${{ env.RELEASE_BIN }}-${{ matrix.suffix }}
asset_name: ${{ env.RELEASE_BIN }}-${{ matrix.suffix }}

- name: Get version
id: get-version
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
if: matrix.os == 'macos-latest'

- name: Bump Homebrew formula
uses: mislav/bump-homebrew-formula-action@v1.12
uses: mislav/bump-homebrew-formula-action@v3
with:
formula-name: pipes-rs
homebrew-tap: lhvy/homebrew-tap
download-url: https://github.com/lhvy/pipes-rs/releases/download/${{ steps.get-version.outputs.version }}/pipes-rs-mac-x86_64.tar.gz
download-url: https://github.com/lhvy/pipes-rs/releases/download/${{ steps.get-version.outputs.version }}/pipes-rs-mac-universal.tar.gz
env:
COMMITTER_TOKEN: ${{ secrets.BREW_TOKEN }}
if: matrix.os == 'macos-latest'
36 changes: 9 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
pull_request:
push:
branches: [master, staging, trying]
branches: master
paths:
- "**.rs"
- "**.toml"
Expand All @@ -24,54 +24,36 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

- name: Load Rust/Cargo cache
uses: Swatinem/rust-cache@v2

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-targets --all-features --locked
run: cargo build --all-features --locked

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features
run: cargo clippy --all-features

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --locked
run: cargo test --all-features --locked

fmt:
name: Formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt -- --check
Loading