Skip to content

Commit

Permalink
Update Build for release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed May 4, 2024
1 parent b587282 commit ecbf259
Showing 1 changed file with 80 additions and 26 deletions.
106 changes: 80 additions & 26 deletions .github/workflows/Build for release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ env:
jobs:
FreeBSD-x86_64-static:
runs-on: ubuntu-latest

steps:
- name: Download source
uses: actions/checkout@v4
Expand All @@ -43,7 +42,7 @@ jobs:
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +'%Y%m%d')
VERSION=$(date +"%Y%m%d")
fi
FILE_NAME="${{ env.Executable }}-$VERSION-freebsd-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
Expand All @@ -63,11 +62,10 @@ jobs:
retention-days: 31

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

Linux-arm64-static:
runs-on: ubuntu-latest

steps:
- name: Download source
uses: actions/checkout@v4
Expand Down Expand Up @@ -99,7 +97,7 @@ jobs:
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +'%Y%m%d')
VERSION=$(date +"%Y%m%d")
fi
FILE_NAME="${{ env.Executable }}-$VERSION-linux-arm64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
Expand All @@ -119,14 +117,12 @@ jobs:
retention-days: 31

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

Linux-x86_64-static:
runs-on: ubuntu-latest

container:
image: crystallang/crystal:latest-alpine

steps:
- name: Download source
uses: actions/checkout@v4
Expand All @@ -145,7 +141,7 @@ jobs:
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +'%Y%m%d')
VERSION=$(date +"%Y%m%d")
fi
FILE_NAME="${{ env.Executable }}-$VERSION-linux-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
Expand All @@ -165,11 +161,10 @@ jobs:
retention-days: 31

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

Windows-x86_64-static:
runs-on: windows-latest

steps:
- name: Download source
uses: actions/checkout@v4
Expand Down Expand Up @@ -197,27 +192,28 @@ jobs:
$FILE_NAME = "${{ env.Executable }}-$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/${{ env.Executable }}.exe" .
$sourcePath = "${{ env.Executable }}.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: |
${{ env.Executable }}.exe
LICENSE
README.md
README_zh.md
path: ${{ steps.get_name.outputs.FILE_NAME }}.zip
retention-days: 31
compression-level: 9

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

macOS-arm64:
runs-on: macos-latest

steps:
- name: Download source
uses: actions/checkout@v4
Expand All @@ -240,7 +236,7 @@ jobs:
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +'%Y%m%d')
VERSION=$(date +"%Y%m%d")
fi
FILE_NAME="${{ env.Executable }}-$VERSION-macos-arm64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
Expand All @@ -260,11 +256,10 @@ jobs:
retention-days: 31

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

macOS-x86_64:
runs-on: macos-13

steps:
- name: Download source
uses: actions/checkout@v4
Expand All @@ -287,7 +282,7 @@ jobs:
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +'%Y%m%d')
VERSION=$(date +"%Y%m%d")
fi
FILE_NAME="${{ env.Executable }}-$VERSION-macos-x86_64"
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_OUTPUT
Expand All @@ -307,19 +302,19 @@ jobs:
retention-days: 31

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

macOS-universal:
needs: [macOS-arm64, macOS-x86_64]
runs-on: ubuntu-latest
needs: [macOS-arm64, macOS-x86_64]
steps:
- name: Generate file name
id: get_name
run: |
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +'%Y%m%d')
VERSION=$(date +"%Y%m%d")
fi
ARM_NAME="${{ env.Executable }}-$VERSION-macos-arm64"
AMD_NAME="${{ env.Executable }}-$VERSION-macos-x86_64"
Expand Down Expand Up @@ -366,4 +361,63 @@ jobs:
retention-days: 31

- name: Output artifact id
run: echo 'Artifact ID is ${{ steps.upload.outputs.artifact-id }}'
run: echo "Artifact ID is ${{ steps.upload.outputs.artifact-id }}"

publish:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [FreeBSD-x86_64-static, Linux-arm64-static, Linux-x86_64-static, Windows-x86_64-static, macOS-universal]
steps:
- name: Generate file name
id: get_name
run: |
if [ ${{ github.event_name }} = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=$(date +"%Y%m%d")
fi
BSD_AMD="${{ env.Executable }}-$VERSION-freebsd-x86_64"
LINUX_ARM="${{ env.Executable }}-$VERSION-linux-arm64"
LINUX_AMD="${{ env.Executable }}-$VERSION-linux-x86_64"
WIN_AMD="${{ env.Executable }}-$VERSION-windows-x86_64-msvc"
MAC_NAME="${{ env.Executable }}-$VERSION-macos-universal"
echo "BSD_AMD=$BSD_AMD" >> $GITHUB_OUTPUT
echo "LINUX_ARM=$LINUX_ARM" >> $GITHUB_OUTPUT
echo "LINUX_AMD=$LINUX_AMD" >> $GITHUB_OUTPUT
echo "WIN_AMD=$WIN_AMD" >> $GITHUB_OUTPUT
echo "MAC_NAME=$MAC_NAME" >> $GITHUB_OUTPUT
- name: Download artifact from FreeBSD-x86_64
uses: actions/download-artifact@v4
with:
name: ${{ steps.get_name.outputs.BSD_AMD }}

- name: Download artifact from Linux-arm64-static
uses: actions/download-artifact@v4
with:
name: ${{ steps.get_name.outputs.LINUX_ARM }}

- name: Download artifact from Linux-x86_64-static
uses: actions/download-artifact@v4
with:
name: ${{ steps.get_name.outputs.LINUX_AMD }}

- name: Download artifact from Windows-x86_64-static
uses: actions/download-artifact@v4
with:
name: ${{ steps.get_name.outputs.WIN_AMD }}

- name: Download artifact from macOS-universal
uses: actions/download-artifact@v4
with:
name: ${{ steps.get_name.outputs.MAC_NAME }}

- name: Publish to Releases
uses: ncipollo/release-action@v1
with:
name: "MockGPT v${{ github.event.release.tag_name }}"
artifactErrorsFailBuild: false
artifacts: "${{ steps.get_name.outputs.BSD_AMD }}.tgz,${{ steps.get_name.outputs.LINUX_ARM }}.tgz,${{ steps.get_name.outputs.LINUX_AMD }}.tgz,${{ steps.get_name.outputs.WIN_AMD }}.zip,${{ steps.get_name.outputs.MAC_NAME }}.tgz"
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true

0 comments on commit ecbf259

Please sign in to comment.