Skip to content

Commit

Permalink
Add GitHub Actions release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowfax92 committed May 18, 2024
1 parent 1889ba2 commit 1c556e9
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Release

on:
push:
tags:
- 'v*.*.*' # Run this workflow only when a tag is pushed

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
target: [x86_64-unknown-linux-gnu, x86_64-pc-windows-gnu, x86_64-apple-darwin]

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

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
default: true

- name: Install dependencies
if: matrix.target == 'x86_64-pc-windows-gnu'
run: sudo apt-get install -y mingw-w64

- name: Build
run: cargo build --release --target ${{ matrix.target }}

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

release:
runs-on: ubuntu-latest
needs: build

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

- 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 Linux
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binaries/x86_64-unknown-linux-gnu/fyin
asset_name: fyin-linux
asset_content_type: application/octet-stream

- name: Upload Release Asset Windows
if: matrix.target == 'x86_64-pc-windows-gnu'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binaries/x86_64-pc-windows-gnu/fyin.exe
asset_name: fyin-windows.exe
asset_content_type: application/octet-stream

- name: Upload Release Asset macOS
if: matrix.target == 'x86_64-apple-darwin'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binaries/x86_64-apple-darwin/fyin
asset_name: fyin-macos
asset_content_type: application/octet-stream

0 comments on commit 1c556e9

Please sign in to comment.