Skip to content

Commit

Permalink
feat: release GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
fcoury committed Jul 2, 2024
1 parent fb82250 commit 4a68aea
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Release

on:
push:
tags:
- "v*.*.*" # Matches version tags like v1.0.0

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install target
run: rustup target add ${{ matrix.target }}

- name: Build for Linux and Windows
if: matrix.target != 'x86_64-apple-darwin' && matrix.target != 'aarch64-apple-darwin'
run: cargo build --release --target ${{ matrix.target }}

- name: Build for macOS
if: matrix.target == 'x86_64-apple-darwin' || matrix.target == 'aarch64-apple-darwin'
uses: docker://ghcr.io/crazy-max/osxcross:latest
with:
entrypoint: /bin/sh
args: -c "cargo build --release --target ${{ matrix.target }}"

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}-release
path: target/${{ matrix.target }}/release/

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.target }}-release
path: ./artifacts

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts
asset_name: ${{ matrix.target }}-release
asset_content_type: application/zip
5 changes: 5 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-apple-darwin]
image = "ghcr.io/cross-rs/x86_64-apple-darwin:latest"

[target.aarch64-apple-darwin]
image = "ghcr.io/cross-rs/aarch64-apple-darwin:latest"

0 comments on commit 4a68aea

Please sign in to comment.