Skip to content

Add readme metadata to Cargo.tom #3

Add readme metadata to Cargo.tom

Add readme metadata to Cargo.tom #3

Workflow file for this run

name: Release AIScript
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build AIScript (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: aiscript
asset_name: aiscript-linux-x86_64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: aiscript
asset_name: aiscript-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: aiscript
asset_name: aiscript-macos-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: aiscript.exe
asset_name: aiscript-windows-x86_64.exe
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Move binary to final location
shell: bash
run: |
mkdir -p dist
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }}
else
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }}
chmod +x dist/${{ matrix.asset_name }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: dist/${{ matrix.asset_name }}
retention-days: 1
if-no-files-found: error
compression-level: 0
release:
needs: build
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
# Add the install.sh script to the release
- name: Prepare install script
run: |
cp install.sh dist/
chmod +x dist/install.sh
# Generate checksums for all artifacts
- name: Generate checksums
run: |
cd dist
find . -type f -not -path "*/\.*" | grep -v "checksums.txt" | xargs -I{} shasum -a 256 {} > checksums.txt
cat checksums.txt
- name: Prepare release files
run: |
mkdir -p release_files
cp dist/aiscript-linux-x86_64/aiscript-linux-x86_64 release_files/
cp dist/aiscript-macos-x86_64/aiscript-macos-x86_64 release_files/
cp dist/aiscript-macos-arm64/aiscript-macos-arm64 release_files/
cp dist/aiscript-windows-x86_64.exe/aiscript-windows-x86_64.exe release_files/
cp dist/install.sh release_files/
cp dist/checksums.txt release_files/
- name: Create release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
echo "Creating release for $VERSION"
# Create the release
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d '{
"tag_name": "'$VERSION'",
"name": "AIScript '$VERSION'",
"body": "Release of AIScript '$VERSION'",
"draft": false,
"prerelease": false,
"generate_release_notes": true
}')
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r .id)
echo "Created release with ID: $RELEASE_ID"
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
# Upload assets
for ASSET in release_files/*; do
ASSET_NAME=$(basename $ASSET)
echo "Uploading $ASSET_NAME..."
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/octet-stream" \
--data-binary @$ASSET \
"https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$ASSET_NAME"
done