Files
rustmailer/.github/workflows/release.yml
T

135 lines
4.0 KiB
YAML

name: Release RustMailer
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Install protoc on Linux
if: runner.os == 'Linux'
run: |
PROTOC_VERSION=31.1
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc
sudo mv protoc/bin/protoc /usr/local/bin/
protoc --version
- name: Install protoc on macOS
if: runner.os == 'macOS'
run: |
PROTOC_VERSION=31.1
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-osx-x86_64.zip
unzip protoc-${PROTOC_VERSION}-osx-x86_64.zip -d protoc
sudo mv protoc/bin/protoc /usr/local/bin/
protoc --version
- name: Install protoc on Windows
if: runner.os == 'Windows'
run: |
Invoke-WebRequest -Uri https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-win64.zip -OutFile protoc.zip
Expand-Archive protoc.zip -DestinationPath protoc
$Env:PATH += ";${PWD}/protoc/bin"
protoc --version
- name: Setup Node.js & pnpm
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install pnpm
run: npm install -g pnpm
- name: Build frontend (web)
working-directory: ./web
run: |
pnpm install
pnpm run build
- name: Install musl-tools (Linux musl only)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build Rust backend
run: cargo build --release --features vendored-openssl --target=${{ matrix.target }}
- name: Prepare dist directory
run: mkdir -p dist
- name: Copy binary to dist
run: |
BIN=rustmailer
EXT=""
if [[ "${{ matrix.target }}" == *windows* ]]; then EXT=".exe"; fi
cp target/${{ matrix.target }}/release/${BIN}${EXT} dist/
- name: Pack artifact
run: |
cd dist
tar -czvf rustmailer-${{ github.ref_name }}-${{ matrix.target }}.tar.gz rustmailer*
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: dist/rustmailer-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Generate changelog with git-cliff
id: changelog
uses: orhun/git-cliff-action@v2
with:
args: --tag ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.content }}
draft: false
prerelease: false
files: ./artifacts/**/*.tar.gz