flappy_bird/.github/workflows/rust.yml

96 lines
2.7 KiB
YAML
Raw Normal View History

2025-01-03 02:02:12 +00:00
name: Release Build
on:
push:
tags:
- 'v*' # Trigger the workflow on new version tags (e.g., v1.0.0)
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: linux-aarch64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: windows-x86_64.exe
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: ${{ matrix.target }}
- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Build the project
run: cargo build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: target/${{ matrix.target }}/release/flappy_bird
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
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 Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/${{ matrix.artifact_name }}
asset_name: ${{ matrix.artifact_name }}
asset_content_type: application/octet-stream