mirror of
https://github.com/bahdotsh/wrkflw.git
synced 2026-09-02 12:16:16 +02:00
150 lines
4.9 KiB
YAML
150 lines
4.9 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to use (e.g. v1.0.0)'
|
|
required: true
|
|
default: 'test-release'
|
|
|
|
# Add permissions at workflow level
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
create-release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
# You can also set permissions at the job level if needed
|
|
# permissions:
|
|
# contents: write
|
|
outputs:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Install git-cliff
|
|
run: |
|
|
cargo install git-cliff --force
|
|
|
|
- name: Generate Changelog
|
|
run: |
|
|
# Debug: Show current state
|
|
echo "Current ref: ${{ github.ref_name }}"
|
|
echo "Input version: ${{ github.event.inputs.version }}"
|
|
echo "All tags:"
|
|
git tag --sort=-version:refname | head -10
|
|
|
|
# Generate changelog from the current tag to the previous version tag
|
|
CURRENT_TAG="${{ github.event.inputs.version || github.ref_name }}"
|
|
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep "^v" | head -2 | tail -1)
|
|
|
|
echo "Current tag: $CURRENT_TAG"
|
|
echo "Previous tag: $PREVIOUS_TAG"
|
|
|
|
if [ -n "$PREVIOUS_TAG" ] && [ "$PREVIOUS_TAG" != "$CURRENT_TAG" ]; then
|
|
echo "Generating changelog for range: $PREVIOUS_TAG..$CURRENT_TAG"
|
|
git-cliff --tag "$CURRENT_TAG" "$PREVIOUS_TAG..$CURRENT_TAG" --output CHANGELOG.md
|
|
else
|
|
echo "Generating latest changelog for tag: $CURRENT_TAG"
|
|
git-cliff --tag "$CURRENT_TAG" --latest --output CHANGELOG.md
|
|
fi
|
|
|
|
echo "Generated changelog:"
|
|
cat CHANGELOG.md
|
|
|
|
- name: Create Release
|
|
id: create_release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
name: "wrkflw ${{ github.event.inputs.version || github.ref_name }}"
|
|
body_path: CHANGELOG.md
|
|
draft: false
|
|
prerelease: false
|
|
tag_name: ${{ github.event.inputs.version || github.ref_name }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
build-release:
|
|
name: Build Release
|
|
needs: [create-release]
|
|
runs-on: ${{ matrix.os }}
|
|
# You can also set permissions at the job level if needed
|
|
# permissions:
|
|
# contents: write
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact_name: wrkflw
|
|
asset_name: wrkflw-${{ github.event.inputs.version || github.ref_name }}-linux-x86_64
|
|
- os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
artifact_name: wrkflw
|
|
asset_name: wrkflw-${{ github.event.inputs.version || github.ref_name }}-macos-x86_64
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact_name: wrkflw
|
|
asset_name: wrkflw-${{ github.event.inputs.version || github.ref_name }}-macos-arm64
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
profile: minimal
|
|
toolchain: stable
|
|
target: ${{ matrix.target }}
|
|
override: true
|
|
|
|
- name: Build Release Binary
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
args: --release --target ${{ matrix.target }}
|
|
|
|
- name: Compress Release Binary (Unix)
|
|
if: runner.os != 'Windows'
|
|
run: |
|
|
mkdir -p compressed
|
|
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} compressed/
|
|
cd compressed
|
|
tar czvf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
|
|
echo "ASSET=${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
|
|
echo "ASSET_PATH=compressed/${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
|
|
|
|
- name: Compress Release Binary (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
mkdir -p compressed
|
|
copy target\${{ matrix.target }}\release\${{ matrix.artifact_name }} compressed\
|
|
cd compressed
|
|
7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
|
|
echo "ASSET=${{ matrix.asset_name }}.zip" >> $env:GITHUB_ENV
|
|
echo "ASSET_PATH=compressed\${{ matrix.asset_name }}.zip" >> $env:GITHUB_ENV
|
|
shell: pwsh
|
|
|
|
- name: Upload Release Asset
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: ${{ env.ASSET_PATH }}
|
|
tag_name: ${{ github.event.inputs.version || github.ref_name }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |