Skip to content

Build and Release Rust Project #7

Build and Release Rust Project

Build and Release Rust Project #7

Workflow file for this run

name: Build and Release Rust Project
on:
push:
tags:
- '*' # Trigger on all tag pushes
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
steps:
# prepare nix and devenv
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
with:
name: devenv
- name: Install devenv.sh
run: nix profile install nixpkgs#devenv
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Build the Rust project
- name: Build project
run: |
cargo build --release
# Upload build artifacts
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: target/release/
# Create a release and upload binaries
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
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: target/release/ # Path to the built binaries
asset_name: build_output.tar.gz # Rename the uploaded artifact
asset_content_type: application/gzip
# Optionally compress the build output
- name: Compress build output
run: |
tar -czvf build_output.tar.gz -C target/release .