Created
January 27, 2023 06:09
-
-
Save dolphin2410/f0e74770bcea6957ca40b814988eefd3 to your computer and use it in GitHub Desktop.
Replace 'mycrate' with your crate's name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push] | |
name: Build | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
artifact: windows | |
filename: mycrate.exe | |
- os: macos-latest | |
artifact: darwin | |
filename: mycrate | |
- os: ubuntu-latest | |
artifact: linux | |
filename: mycrate | |
name: build | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Update Rust | |
run: rustup update # msrv 1.65.0 | |
- name: build | |
run: cargo build --release | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.artifact }} | |
path: target/release/${{ matrix.filename }} | |
upload: | |
needs: [build] | |
name: Upload Artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# Download artifacts | |
- uses: actions/download-artifact@v2 | |
with: | |
name: windows | |
path: output/windows/mycrate | |
- uses: actions/download-artifact@v2 | |
with: | |
name: linux | |
path: output/linux/mycrate | |
- uses: actions/download-artifact@v2 | |
with: | |
name: darwin | |
path: output/darwin/mycrate | |
# Parse version to output | |
- name: Get version | |
run: echo "::set-output name=version::$(grep -Po '(?<=version = \").+(?=\")' Cargo.toml)" | |
id: version | |
# Create Release | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.version.outputs.version }} | |
release_name: Release ${{ steps.version.outputs.version }} | |
draft: false | |
prerelease: false | |
continue-on-error: true | |
# Upload Windows Asset | |
- name: Upload Release Asset (Windows) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: output/windows/mycrate/mycrate.exe | |
asset_name: mycrate-windows.exe | |
asset_content_type: application/vnd.microsoft.portable-executable | |
continue-on-error: true | |
# Upload Linux Assets | |
- name: Upload Release Asset (Linux) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: output/linux/mycrate/mycrate | |
asset_name: mycrate-linux | |
asset_content_type: application/x-binary | |
continue-on-error: true | |
# Upload Darwin assets | |
- name: Upload Release Asset (Darwin) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: output/darwin/mycrate/mycrate | |
asset_name: mycrate-darwin | |
asset_content_type: application/x-binary | |
continue-on-error: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment