Workflow file for this run
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: | |
release: | |
types: [created] | |
permissions: | |
contents: write | |
jobs: | |
update-version: | |
runs-on: ubuntu-latest | |
outputs: | |
default-branch: ${{ steps.env.outputs.default-branch }} | |
remote: ${{ steps.env.outputs.remote }} | |
steps: | |
- name: ⬇️ Checkout | |
uses: actions/checkout@v3 | |
- name: ⚙️ Setup environment | |
id: env | |
run: | | |
REMOTE=origin | |
DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') | |
echo "remote=$REMOTE" >> $GITHUB_OUTPUT | |
echo "default-branch=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT | |
echo "Branch $DEFAULT_BRANCH on remote $REMOTE" | |
- name: 📝 Update version from git tag | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
git fetch --tags | |
git checkout ${{ steps.env.outputs.default-branch }} | |
git pull ${{ steps.env.outputs.remote }} ${{ steps.env.outputs.default-branch }} | |
VERSION="${GITHUB_REF#refs/tags/}" | |
VERSION="${VERSION#v}" # Remove 'v' prefix if present | |
echo "Updating version to $VERSION in Cargo.toml" | |
sed -i -E "s/^version = \"[^\"]+\"/version = \"$VERSION\"/" Cargo.toml | |
git add Cargo.toml | |
git add Cargo.lock | |
git commit -m "Bump version to $VERSION" | |
git push ${{ steps.env.outputs.remote }} ${{ steps.env.outputs.default-branch }} | |
build: | |
needs: update-version | |
strategy: | |
matrix: | |
os: | |
- windows-latest | |
- ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: ⬇️ Checkout | |
uses: actions/checkout@v3 | |
- name: ⬇️ Force fetch of repo to get the absolute latest version | |
run: | | |
git fetch --tags | |
git checkout ${{ needs.update-version.outputs.default-branch }} | |
git pull ${{ needs.update-version.outputs.remote }} ${{ needs.update-version.outputs.default-branch }} | |
- name: ⚙️ Install UPX | |
uses: crazy-max/ghaction-upx@v3 | |
with: | |
install-only: true | |
- name: ⬇️ Setup Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: 📦 Build binary | |
run: cargo build --release | |
- name: 📦 Compress binary with UPX (Windows) | |
if: runner.os == 'Windows' | |
run: upx --best --lzma target\\release\\mail-sink.exe | |
- name: 📦 Compress binary with UPX (Linux) | |
if: runner.os == 'Linux' | |
run: upx --best --lzma target/release/mail-sink | |
- name: 🚀 Upload Release Assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: target/release/mail-sink* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |