From ecbf2597690a689a24182affd659077019f6d49b Mon Sep 17 00:00:00 2001 From: Sunrise Date: Sat, 4 May 2024 23:46:39 +0800 Subject: [PATCH] Update Build for release.yml --- .github/workflows/Build for release.yml | 106 ++++++++++++++++++------ 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/.github/workflows/Build for release.yml b/.github/workflows/Build for release.yml index b465163..393c93f 100644 --- a/.github/workflows/Build for release.yml +++ b/.github/workflows/Build for release.yml @@ -18,7 +18,6 @@ env: jobs: FreeBSD-x86_64-static: runs-on: ubuntu-latest - steps: - name: Download source uses: actions/checkout@v4 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -307,11 +302,11 @@ 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 @@ -319,7 +314,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 ARM_NAME="${{ env.Executable }}-$VERSION-macos-arm64" AMD_NAME="${{ env.Executable }}-$VERSION-macos-x86_64" @@ -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