Takajo Release Automation #66
This file contains 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: Takajo Release Automation | |
on: | |
workflow_dispatch: | |
inputs: | |
release_ver: | |
required: true | |
default: "2.x.x" | |
branch_or_tag: | |
required: true | |
default: "main" | |
jobs: | |
release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest, macos-12] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.branch_or_tag }} | |
- name: Setup Nim | |
uses: jiro4989/setup-nim-action@v2 | |
with: | |
nim-version: '2.x' # default is 'stable' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update nimble libraries | |
run: | | |
nimble update | |
- name: Build Takajo binary | |
if: matrix.os != 'macos-12' | |
run: | | |
nimble build -d:release --threads:on | |
- name: Build Takajo binary for Intel Mac | |
if: matrix.os == 'macos-12' | |
run: | | |
nimble build -d:release --threads:on --os:macosx --cpu:amd64 | |
- name: Package and Zip - Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
mkdir -p release-binaries | |
Copy-Item -Path takajo.exe -Destination release-binaries/ | |
mv release-binaries/takajo.exe release-binaries/takajo-${{ github.event.inputs.release_ver }}-win-x64.exe | |
Copy-Item -Path mitre-attack.json -Destination release-binaries/ | |
Copy-Item -Path pcre64.dll -Destination release-binaries/ | |
Copy-Item -Path sqlite3_64.dll -Destination release-binaries/ | |
Copy-Item -Path templates -Destination release-binaries/ -Recurse | |
mkdir -p release-binaries/src/takajopkg/web/ | |
Copy-Item -Path src/takajopkg/web/static -Destination release-binaries/src/takajopkg/web/ -Recurse | |
- name: Package and Zip - Unix | |
if: matrix.os != 'windows-latest' | |
run: | | |
mkdir -p release-binaries | |
cp takajo release-binaries/ | |
cp mitre-attack.json release-binaries/ | |
cp -r templates release-binaries/ | |
mkdir -p release-binaries/src/takajopkg/web/ | |
cp -r src/takajopkg/web/static release-binaries/src/takajopkg/web/ | |
case ${{ matrix.os }} in | |
'ubuntu-latest') | |
mv release-binaries/takajo release-binaries/takajo-${{ github.event.inputs.release_ver }}-lin-x64-gnu ;; | |
'macos-latest') | |
mv release-binaries/takajo release-binaries/takajo-${{ github.event.inputs.release_ver }}-mac-aarch64 ;; | |
'macos-12') | |
mv release-binaries/takajo release-binaries/takajo-${{ github.event.inputs.release_ver }}-mac-x64 ;; | |
esac | |
- name: Set Artifact Name | |
id: set_artifact_name | |
shell: bash | |
run: | | |
case "${{ matrix.os }}" in | |
'windows-latest') | |
echo "artifact_name=takajo-${{ github.event.inputs.release_ver }}-win-x64" >> $GITHUB_OUTPUT ;; | |
'ubuntu-latest') | |
echo "artifact_name=takajo-${{ github.event.inputs.release_ver }}-linux-intel" >> $GITHUB_OUTPUT ;; | |
'macos-latest') | |
echo "artifact_name=takajo-${{ github.event.inputs.release_ver }}-mac-arm" >> $GITHUB_OUTPUT ;; | |
'macos-12') | |
echo "artifact_name=takajo-${{ github.event.inputs.release_ver }}-mac-intel" >> $GITHUB_OUTPUT ;; | |
esac | |
- name: Upload Zip Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.set_artifact_name.outputs.artifact_name }} | |
path: | | |
release-binaries/* | |
- name: Setup node | |
if: matrix.os == 'macos-latest' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Create PDF | |
if: matrix.os == 'macos-latest' | |
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 | |
mv ./CHANGELOG.pdf ./CHANGELOG-${{ github.event.inputs.release_ver }}-English.pdf | |
mv ./CHANGELOG-Japanese.pdf ./CHANGELOG-${{ github.event.inputs.release_ver }}-Japanese.pdf | |
- name: Upload Document Artifacts | |
if: matrix.os == 'macos-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: documents | |
path: | | |