Skip to content

feat: Improve release workflow and fix binary naming #78

feat: Improve release workflow and fix binary naming

feat: Improve release workflow and fix binary naming #78

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
jobs:
build-and-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build-linux-x86:
needs: build-and-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-unknown-linux-gnu
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aicommit-linux-x86_64
path: ./target/x86_64-unknown-linux-gnu/release/aicommit
if-no-files-found: error
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build-and-release.outputs.upload_url }}
asset_path: ./target/x86_64-unknown-linux-gnu/release/aicommit
asset_name: aicommit-linux-x86_64
asset_content_type: application/octet-stream
build-macos-x86:
needs: build-and-release
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-apple-darwin
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aicommit-macos-x86_64
path: ./target/x86_64-apple-darwin/release/aicommit
if-no-files-found: error
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build-and-release.outputs.upload_url }}
asset_path: ./target/x86_64-apple-darwin/release/aicommit
asset_name: aicommit-macos-x86_64
asset_content_type: application/octet-stream
build-macos-arm:
needs: build-and-release
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-apple-darwin
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target aarch64-apple-darwin
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aicommit-macos-aarch64
path: ./target/aarch64-apple-darwin/release/aicommit
if-no-files-found: error
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build-and-release.outputs.upload_url }}
asset_path: ./target/aarch64-apple-darwin/release/aicommit
asset_name: aicommit-macos-aarch64
asset_content_type: application/octet-stream
build-windows-x86:
needs: build-and-release
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-pc-windows-msvc
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aicommit-windows-x86_64
path: ./target/x86_64-pc-windows-msvc/release/aicommit.exe
if-no-files-found: error
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build-and-release.outputs.upload_url }}
asset_path: ./target/x86_64-pc-windows-msvc/release/aicommit.exe
asset_name: aicommit-windows-x86_64.exe
asset_content_type: application/octet-stream
build-windows-arm:
needs: build-and-release
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-pc-windows-msvc
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target aarch64-pc-windows-msvc
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aicommit-windows-aarch64
path: ./target/aarch64-pc-windows-msvc/release/aicommit.exe
if-no-files-found: error
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build-and-release.outputs.upload_url }}
asset_path: ./target/aarch64-pc-windows-msvc/release/aicommit.exe
asset_name: aicommit-windows-aarch64.exe
asset_content_type: application/octet-stream
publish-crates:
needs: build-and-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Publish to crates.io
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --allow-dirty
publish-npm:
needs: [build-and-release, build-linux-x86, build-macos-x86, build-macos-arm, build-windows-x86, build-windows-arm]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Create bin directory
run: mkdir -p bin
- name: Download Linux x86_64
uses: actions/download-artifact@v4
with:
name: aicommit-linux-x86_64
path: bin
- name: Download macOS x86_64
uses: actions/download-artifact@v4
with:
name: aicommit-macos-x86_64
path: bin
- name: Download macOS ARM64
uses: actions/download-artifact@v4
with:
name: aicommit-macos-aarch64
path: bin
- name: Download Windows x86_64
uses: actions/download-artifact@v4
with:
name: aicommit-windows-x86_64
path: bin
- name: Download Windows ARM64
uses: actions/download-artifact@v4
with:
name: aicommit-windows-aarch64
path: bin
- name: Move binaries to correct location
run: |
mkdir -p bin
echo "Current directory structure:"
find bin -type f -ls
# Перемещаем файлы с правильными именами
for file in bin/*/aicommit*; do
dir=$(dirname "$file")
platform=$(basename "$dir")
echo "Processing $file from $platform"
case "$platform" in
"aicommit-linux-x86_64")
mv "$file" "bin/aicommit-linux-x86_64"
;;
"aicommit-macos-x86_64")
mv "$file" "bin/aicommit-macos-x86_64"
;;
"aicommit-macos-aarch64")
mv "$file" "bin/aicommit-macos-aarch64"
;;
"aicommit-windows-x86_64")
mv "$file" "bin/aicommit-windows-x86_64.exe"
;;
"aicommit-windows-aarch64")
mv "$file" "bin/aicommit-windows-aarch64.exe"
;;
esac
done
# Удаляем пустые директории
rm -rf bin/*/
echo "Final bin directory contents:"
ls -la bin/
file bin/* || true
chmod +x bin/aicommit-*
- name: Publish to npm
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}