Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate Binary Releases for Noname #173

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Auto Release on Changelog Change

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Parse latest version from changelog
id: parse_version
run: |
# Extract the latest version from the changelog
latest_version=$(grep -oP '## \[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -n 1)
echo "Latest version from changelog: $latest_version"
echo "::set-output name=latest_version::$latest_version"

- name: Get the latest release version
id: get_latest_release
run: |
latest_release=$(gh release list --limit 1 | grep -oP '^v\K[0-9]+\.[0-9]+\.[0-9]+')
echo "Latest release version: $latest_release"
echo "::set-output name=latest_release::$latest_release"

- name: Determine if a new release is needed
id: check_release
run: |
if [ "${{ steps.parse_version.outputs.latest_version }}" == "${{ steps.get_latest_release.outputs.latest_release }}" ]; then
echo "No new version to release."
echo "::set-output name=needs_release::false"
else
echo "New version found. Release needed."
echo "::set-output name=needs_release::true"
fi

- name: Build the Project
if: steps.check_release.outputs.needs_release == 'true'
run: cargo build --release

- name: Install GitHub CLI
if: steps.check_release.outputs.needs_release == 'true'
run: sudo apt-get install gh

- name: Authenticate GitHub CLI
if: steps.check_release.outputs.needs_release == 'true'
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token

- name: Create Release
if: steps.check_release.outputs.needs_release == 'true'
run: |
gh release create v${{ steps.parse_version.outputs.latest_version }} target/release/noname --title "Release v${{ steps.parse_version.outputs.latest_version }}"

- name: Upload assets
if: steps.check_release.outputs.needs_release == 'true'
run: |
gh release upload v${{ steps.parse_version.outputs.latest_version }} target/release/noname --clobber
Loading