Skip to content

Update Build for release.yml #6

Update Build for release.yml

Update Build for release.yml #6

name: Build for release
on:
push:
paths:
- ".github/workflows/Build for release.yml"
pull_request:
paths:
- ".github/workflows/Build for release.yml"
release:
types: [published]
schedule:
- cron: "0 6 * * 1" # Every Monday 6 AM
jobs:
FreeBSD-static:
runs-on: ubuntu-latest
env:
MYTOKEN: ${{ secrets.MYTOKEN }}
outputs:
FILE_NAME: ${{ steps.get_name.outputs.FILE_NAME }}
steps:
- name: Download source
uses: actions/checkout@v4
- name: Build in FreeBSD-vm
id: build
uses: vmactions/freebsd-vm@v1
with:
envs: "MYTOKEN"
usesh: true
prepare: |
pkg install -y crystal shards
run: |
pwd
ls -lah
whoami
env
freebsd-version
crystal version
shards install
crystal spec --order=random
shards build --production --release --no-debug -Dpreview_mt --static
- name: Generate file name
id: get_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(date +'%Y%m%d')
fi
FILE_NAME="mockgpt-$VERSION-freebsd-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
echo "Generated file name: $FILE_NAME"
- name: Collect assets
run: |
mv bin/mockgpt .
tar -cvzf ${{ steps.get_name.outputs.FILE_NAME }}.tgz mockgpt LICENSE README.md README_zh.md
- name: Upload artifact
uses: actions/upload-artifact@v4
id: upload
with:
name: ${{ steps.get_name.outputs.FILE_NAME }}
path: ${{ steps.get_name.outputs.FILE_NAME }}.tgz
retention-days: 7
- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
Linux-static:
runs-on: ubuntu-latest
container:
image: crystallang/crystal:latest-alpine
steps:
- name: Download source
uses: actions/checkout@v4
- name: Build in container
run: |
crystal version
shards install
crystal spec --order=random
shards build --production --release --no-debug -Dpreview_mt --static
- name: Generate file name
id: get_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(date +'%Y%m%d')
fi
FILE_NAME="mockgpt-$VERSION-linux-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
echo "Generated file name: $FILE_NAME"
- name: Collect assets
run: |
mv bin/mockgpt .
tar -cvzf ${{ steps.get_name.outputs.FILE_NAME }}.tgz mockgpt LICENSE README.md README_zh.md
- name: Upload artifact
uses: actions/upload-artifact@v4
id: upload
with:
name: ${{ steps.get_name.outputs.FILE_NAME }}
path: ${{ steps.get_name.outputs.FILE_NAME }}.tgz
retention-days: 7
- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
macOS-x86_64:
runs-on: macos-latest
steps:
- name: Download source
uses: actions/checkout@v4
- name: Install Crystal
uses: crystal-lang/[email protected]
with:
crystal: latest
- name: Build
run: |
crystal version
shards install
crystal spec --order=random
shards build --production --release --no-debug -Dpreview_mt
- name: Generate file name
id: get_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(date +'%Y%m%d')
fi
FILE_NAME="mockgpt-$VERSION-macos-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
echo "Generated file name: $FILE_NAME"
- name: Collect assets
run: |
mv bin/mockgpt .
tar -cvzf ${{ steps.get_name.outputs.FILE_NAME }}.tgz mockgpt LICENSE README.md README_zh.md
- name: Upload artifact
uses: actions/upload-artifact@v4
id: upload
with:
name: ${{ steps.get_name.outputs.FILE_NAME }}
path: ${{ steps.get_name.outputs.FILE_NAME }}.tgz
retention-days: 7
- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
Windows-static:
runs-on: windows-latest
steps:
- name: Download source
uses: actions/checkout@v4
- name: Install Crystal
uses: crystal-lang/[email protected]
with:
crystal: latest
- name: Build
run: |
crystal version
shards install
crystal spec --order=random
shards build --production --release --no-debug -Dpreview_mt --static
- name: Generate file name
id: get_name
run: |
if ("${{ github.event_name }}" -eq "release") {
$VERSION = $env:GITHUB_REF -replace "refs/tags/"
} else {
$VERSION = Get-Date -Format 'yyyyMMdd'
}
$FILE_NAME = "mockgpt-$VERSION-windows-x86_64-msvc"
Add-Content -Path $env:GITHUB_OUTPUT -Value "FILE_NAME=$FILE_NAME"
Write-Host "Generated file name: $FILE_NAME"
- name: Collect assets
run: |
mv bin/mockgpt.exe .
$sourcePath = "mockgpt.exe", "LICENSE", "README.md", "README_zh.md"
$destinationPath = "${{ steps.get_name.outputs.FILE_NAME }}.zip"
Compress-Archive -CompressionLevel "Optimal" -Path $sourcePath -DestinationPath $destinationPath
- name: Upload artifact
uses: actions/upload-artifact@v4
id: upload
with:
name: ${{ steps.get_name.outputs.FILE_NAME }}
path: ${{ steps.get_name.outputs.FILE_NAME }}.zip
retention-days: 7
compression-level: 9
- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'