Skip to content

feat: Implement \set PROMPT1, PROMPT2, and PROMPT3 commands for Fireb… #6

feat: Implement \set PROMPT1, PROMPT2, and PROMPT3 commands for Fireb…

feat: Implement \set PROMPT1, PROMPT2, and PROMPT3 commands for Fireb… #6

Workflow file for this run

name: Release on Version Change
on:
push:
branches:
- main
jobs:
build:
uses: ./.github/workflows/build-static.yml
release:
runs-on: ubuntu-latest
needs: ['build']
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest released version
id: releases
run: |
LATEST_RELEASE_JSON=$(curl -sL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${{ github.api_url }}/repos/${{ github.repository }}/releases/latest")
TAG_NAME=$(echo "$LATEST_RELEASE_JSON" | jq -r .tag_name)
if [ "$TAG_NAME" = "null" ]; then
echo "ERROR: no released versions exist" 1>&2
exit 1
else
# remove the leading 'v' from the tag name
echo "latest_version=${TAG_NAME:1}" >> "$GITHUB_OUTPUT"
echo "🕰️ Latest released version: $TAG_NAME" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Get current version from Cargo.toml
id: main_branch
run: |
CURRENT_VERSION=$(grep '^version' Cargo.toml | head -n 1 | awk -F '"' '{print $2}')
echo "version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "📝 Version detected in Cargo.toml: $CURRENT_VERSION" >> "$GITHUB_STEP_SUMMARY"
- name: Compare versions
id: compare_versions
run: |
LATEST_VERSION="${{ steps.releases.outputs.latest_version }}"
MAIN_BRANCH_VERSION="${{ steps.main_branch.outputs.version }}"
# Use sort -V to compare the versions numerically.
# If MAIN_BRANCH_VERSION is truly greater, it will be the second item
# when sorted, and they must not be identical.
if [ "$(printf '%s\n' "$MAIN_BRANCH_VERSION" "$LATEST_VERSION" | sort -V | head -n 1)" = "$LATEST_VERSION" ] && \
[ "$MAIN_BRANCH_VERSION" != "$LATEST_VERSION" ]; then
echo "needs_release=true" >> "$GITHUB_OUTPUT"
fi
- name: Download x86_64 binary
if: steps.compare_versions.outputs.needs_release
uses: actions/download-artifact@v4
with:
name: fb-linux-static-x86_64
- name: Download aarch64 binary
if: steps.compare_versions.outputs.needs_release
uses: actions/download-artifact@v4
with:
name: fb-linux-static-aarch64
- name: Generate release notes
if: steps.compare_versions.outputs.needs_release
id: release_notes
run: |
git log v${{ steps.releases.outputs.latest_version }}..HEAD --pretty=format:"* %s [%h](https://github.com/${{ github.repository }}/commit/%H)" > release_notes.md
- name: Create GitHub Release if version changed
if: steps.compare_versions.outputs.needs_release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.main_branch.outputs.version }}
release_name: Release v${{ steps.main_branch.outputs.version }}
body_path: release_notes.md
- name: Upload x86_64 binary onto release
if: steps.compare_versions.outputs.needs_release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: fb-linux-static-x86_64
asset_name: fb-linux-static-x86_64
asset_content_type: application/octet-stream
- name: Upload aarch64 binary onto release
if: steps.compare_versions.outputs.needs_release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: fb-linux-static-aarch64
asset_name: fb-linux-static-aarch64
asset_content_type: application/octet-stream