Skip to content

fix: update release workflow to use modern actions with proper permis… #2

fix: update release workflow to use modern actions with proper permis…

fix: update release workflow to use modern actions with proper permis… #2

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Generate changelog
echo "## What's Changed" > RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
# Get commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
git log --pretty=format:"- %s" $LAST_TAG..HEAD >> RELEASE_NOTES.md
else
echo "- Initial release" >> RELEASE_NOTES.md
fi
echo "" >> RELEASE_NOTES.md
echo "## Downloads" >> RELEASE_NOTES.md
echo "Choose the binary for your platform:" >> RELEASE_NOTES.md
echo "- **Linux x86_64**: \`docsee-linux-x86_64\`" >> RELEASE_NOTES.md
echo "- **Linux ARM64**: \`docsee-linux-aarch64\`" >> RELEASE_NOTES.md
echo "- **macOS Intel**: \`docsee-macos-x86_64\`" >> RELEASE_NOTES.md
echo "- **macOS Apple Silicon**: \`docsee-macos-aarch64\`" >> RELEASE_NOTES.md
echo "- **Windows**: \`docsee-windows-x86_64.exe\`" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "## Installation" >> RELEASE_NOTES.md
echo "\`\`\`bash" >> RELEASE_NOTES.md
echo "# Download and install (Linux/macOS)" >> RELEASE_NOTES.md
echo "curl -L https://github.com/${{ github.repository }}/releases/download/$VERSION/docsee-linux-x86_64 -o docsee" >> RELEASE_NOTES.md
echo "chmod +x docsee" >> RELEASE_NOTES.md
echo "sudo mv docsee /usr/local/bin/" >> RELEASE_NOTES.md
echo "\`\`\`" >> RELEASE_NOTES.md
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ steps.changelog.outputs.version }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
build-and-upload:
name: Build and Upload (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: docsee-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: docsee-linux-aarch64
- target: x86_64-apple-darwin
os: macos-latest
name: docsee-macos-x86_64
- target: aarch64-apple-darwin
os: macos-latest
name: docsee-macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: docsee-windows-x86_64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-release-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
# Install cross for robust cross-compilation
cargo install cross --git https://github.com/cross-rs/cross
# Also install traditional tools as backup
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Configure linker (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
mkdir -p ~/.cargo
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- name: Build release binary
shell: bash
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
# Use cross for ARM64 Linux builds
cross build --release --target ${{ matrix.target }}
else
# Use standard cargo for other targets
cargo build --release --target ${{ matrix.target }}
fi
- name: Prepare binary (Unix)
if: matrix.os != 'windows-latest'
shell: bash
run: |
cp target/${{ matrix.target }}/release/docsee ${{ matrix.name }}
chmod +x ${{ matrix.name }}
# Create compressed archive
tar -czf ${{ matrix.name }}.tar.gz ${{ matrix.name }}
# Generate checksum
sha256sum ${{ matrix.name }} > ${{ matrix.name }}.sha256
- name: Prepare binary (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Copy-Item "target\${{ matrix.target }}\release\docsee.exe" "${{ matrix.name }}"
# Create compressed archive
Compress-Archive -Path "${{ matrix.name }}" -DestinationPath "${{ matrix.name }}.zip"
# Generate checksum
(Get-FileHash "${{ matrix.name }}" -Algorithm SHA256).Hash.ToLower() + " ${{ matrix.name }}" | Out-File -FilePath "${{ matrix.name }}.sha256" -Encoding ASCII
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
files: |
${{ matrix.name }}
${{ matrix.name }}.tar.gz
${{ matrix.name }}.zip
${{ matrix.name }}.sha256
update-homebrew:
name: Update Homebrew Formula
runs-on: ubuntu-latest
needs: [create-release, build-and-upload]
if: "!contains(github.ref, 'rc') && !contains(github.ref, 'beta')"
steps:
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Update Homebrew formula
run: |
echo "Homebrew formula update would go here"
echo "Version: ${{ steps.version.outputs.version }}"
# This would update a homebrew-tap repository
# For now, we'll skip this and implement it in Phase 2