Suzaku Release Automation #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Suzaku Release Automation | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_ver: | |
| required: true | |
| default: "0.0.x" | |
| description: "Version of the release" | |
| branch_or_tag: | |
| required: true | |
| default: "main" | |
| description: "Branch or Tag to checkout" | |
| jobs: | |
| upload: | |
| runs-on: ${{ matrix.info.os }} | |
| strategy: | |
| matrix: | |
| info: | |
| - { | |
| os: "windows-latest", | |
| target: "x86_64-pc-windows-msvc", | |
| } | |
| - { | |
| os: "windows-latest", | |
| target: "i686-pc-windows-msvc", | |
| } | |
| - { | |
| os: "windows-latest", | |
| target: "aarch64-pc-windows-msvc", | |
| } | |
| - { | |
| os: "ubuntu-latest", | |
| target: "x86_64-unknown-linux-gnu", | |
| } | |
| - { | |
| os: "ubuntu-latest", | |
| target: "x86_64-unknown-linux-musl", | |
| } | |
| - { | |
| os: "ubuntu-latest", | |
| target: "aarch64-unknown-linux-gnu", | |
| } | |
| - { | |
| os: "macos-latest", | |
| target: "aarch64-apple-darwin", | |
| } | |
| - { | |
| os: "macos-latest", | |
| target: "x86_64-apple-darwin", | |
| } | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.branch_or_tag }} | |
| submodules: 'true' | |
| - name: Clone Suzaku rule repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| repository: Yamato-Security/suzaku-rules | |
| fetch-depth: 0 | |
| path: suzaku-rules | |
| - name: Set up Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.info.target }} | |
| - name: Install gcc-aarch64-linux-gnu | |
| if: matrix.info.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install gcc-aarch64-linux-gnu | |
| cat << EOF >> ./.cargo/config.toml | |
| [target.aarch64-unknown-linux-gnu] | |
| linker = "aarch64-linux-gnu-gcc" | |
| EOF | |
| - name: Install x86_64-unknown-linux-musl | |
| if: matrix.info.target == 'x86_64-unknown-linux-musl' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install musl-tools | |
| - name: Build Suzaku binary | |
| run: | | |
| cargo build --release --target ${{ matrix.info.target }} | |
| - name: Package and Zip - Windows | |
| if: contains(matrix.info.os, 'windows') == true | |
| shell: pwsh | |
| run: | | |
| mkdir -p release-binaries | |
| Copy-Item -Path ./target/${{ matrix.info.target }}/release/suzaku.exe -Destination release-binaries/ | |
| Copy-Item -Recurse -Path ./config -Destination release-binaries/ | |
| Copy-Item -Recurse -Path ./art -Destination release-binaries/ | |
| Remove-Item -Path ./suzaku-rules/.gitignore -Force | |
| Remove-Item -Path ./suzaku-rules/*.md -Force | |
| Remove-Item -Path ./suzaku-rules/.github -Recurse -Force | |
| Copy-Item -Recurse -Path ./suzaku-rules/ -Destination release-binaries/rules -Force | |
| switch ("${{ matrix.info.target }}") { | |
| "x86_64-pc-windows-msvc" { | |
| mv release-binaries/suzaku.exe release-binaries/suzaku-${{ github.event.inputs.release_ver }}-win-x64.exe | |
| } | |
| "i686-pc-windows-msvc" { | |
| mv release-binaries/suzaku.exe release-binaries/suzaku-${{ github.event.inputs.release_ver }}-win-x86.exe | |
| } | |
| "aarch64-pc-windows-msvc" { | |
| mv release-binaries/suzaku.exe release-binaries/suzaku-${{ github.event.inputs.release_ver }}-win-aarch64.exe | |
| } | |
| } | |
| - name: Package and Zip - Unix | |
| if: contains(matrix.info.os, 'windows') == false | |
| run: | | |
| mkdir -p release-binaries | |
| cp ./target/${{ matrix.info.target }}/release/suzaku release-binaries/ | |
| cp -r ./config release-binaries/config | |
| cp -r ./art release-binaries/art | |
| rm -f ./suzaku-rules/.gitignore | |
| rm -f ./suzaku-rules/*.md | |
| rm -rf ./suzaku-rules/.github | |
| cp -r ./suzaku-rules/. release-binaries/rules | |
| case ${{ matrix.info.target }} in | |
| 'x86_64-unknown-linux-gnu') | |
| mv release-binaries/suzaku release-binaries/suzaku-${{ github.event.inputs.release_ver }}-lin-x64-gnu ;; | |
| 'x86_64-unknown-linux-musl') | |
| mv release-binaries/suzaku release-binaries/suzaku-${{ github.event.inputs.release_ver }}-lin-x64-musl ;; | |
| 'aarch64-unknown-linux-gnu') | |
| mv release-binaries/suzaku release-binaries/suzaku-${{ github.event.inputs.release_ver }}-lin-aarch64-gnu ;; | |
| 'aarch64-apple-darwin') | |
| mv release-binaries/suzaku release-binaries/suzaku-${{ github.event.inputs.release_ver }}-mac-aarch64 ;; | |
| 'x86_64-apple-darwin') | |
| mv release-binaries/suzaku release-binaries/suzaku-${{ github.event.inputs.release_ver }}-mac-x64 ;; | |
| esac | |
| - name: Set Artifact Name | |
| id: set_artifact_name | |
| shell: bash | |
| run: | | |
| case "${{ matrix.info.target }}" in | |
| 'x86_64-pc-windows-msvc') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-win-x64" >> $GITHUB_OUTPUT ;; | |
| 'i686-pc-windows-msvc') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-win-x86" >> $GITHUB_OUTPUT ;; | |
| 'aarch64-pc-windows-msvc') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-win-aarch64" >> $GITHUB_OUTPUT ;; | |
| 'x86_64-unknown-linux-gnu') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-lin-x64-gnu" >> $GITHUB_OUTPUT ;; | |
| 'x86_64-unknown-linux-musl') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-lin-x64-musl" >> $GITHUB_OUTPUT ;; | |
| 'aarch64-unknown-linux-gnu') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-lin-aarch64-gnu" >> $GITHUB_OUTPUT ;; | |
| 'aarch64-apple-darwin') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-mac-aarch64" >> $GITHUB_OUTPUT ;; | |
| 'x86_64-apple-darwin') | |
| echo "artifact_name=suzaku-${{ github.event.inputs.release_ver }}-mac-x64" >> $GITHUB_OUTPUT ;; | |
| esac | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.set_artifact_name.outputs.artifact_name }} | |
| path: release-binaries/* | |
| include-hidden-files: true | |
| - name: Setup node | |
| if: matrix.info.target == 'aarch64-apple-darwin' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Create PDF | |
| if: matrix.info.target == 'aarch64-apple-darwin' | |
| run: | | |
| npm i -g md-to-pdf | |
| md-to-pdf ./*.md --md-file-encoding utf-8 | |
| mv ./README.pdf ./README-${{ github.event.inputs.release_ver }}-English.pdf | |
| mv ./README-Japanese.pdf ./README-${{ github.event.inputs.release_ver }}-Japanese.pdf | |
| - name: Upload Document Artifacts | |
| if: matrix.info.target == 'aarch64-apple-darwin' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: suzaku-documents | |
| path: | | |
| upload-all-platforms: | |
| needs: upload | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download All Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: all-packages | |
| pattern: suzaku-* | |
| merge-multiple: true | |
| - name: Upload Artifacts(all-platforms) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: suzaku-${{ github.event.inputs.release_ver }}-all-platforms | |
| path: all-packages/* | |
| include-hidden-files: true | |
| all-packages-zip: | |
| needs: upload-all-platforms | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: all-packages | |
| pattern: suzaku-* | |
| - run: | | |
| ls -lR all-packages | |
| cd all-packages | |
| for dir in */; do | |
| cd "$dir" | |
| zip -r "../${dir%/}.zip" * | |
| cd .. | |
| done | |
| - name: Upload Zip Artifacts(all-packages) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-packages | |
| path: all-packages/*.zip |