61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and Release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Get Version
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(grep '^version =' Cargo.toml | head -n1 | cut -d '"' -f 2)
|
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
|
echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Build
|
|
run: cargo build --release
|
|
|
|
- name: Create Release
|
|
id: create_release
|
|
uses: https://github.com/actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ steps.get_version.outputs.TAG }}
|
|
release_name: Release ${{ steps.get_version.outputs.TAG }}
|
|
body: |
|
|
Automated release for version ${{ steps.get_version.outputs.VERSION }}
|
|
Commit: ${{ github.sha }}
|
|
Branch: ${{ github.ref_name }}
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Upload Release Asset
|
|
uses: https://github.com/actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ./target/release/cenv
|
|
asset_name: cenv-${{ steps.get_version.outputs.TAG }}-linux-amd64
|
|
asset_content_type: application/octet-stream
|