Takajo Release Automation #85
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-13] | |
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-13' | |
run: | | |
nimble build -d:release --threads:on | |
- name: Build Takajo binary for Intel Mac | |
if: matrix.os == 'macos-13' | |
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 | |
New-Item -Path release-binaries/src/takajopkg/web/static/js/common.js -ItemType file | |
- 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/ | |
mkdir -p release-binaries/src/takajopkg/web/static/js | |
touch release-binaries/src/takajopkg/web/static/js/common.js | |
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-13') | |
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 }}-lin-x64-gnu" >> $GITHUB_OUTPUT ;; | |
'macos-latest') | |
echo "artifact_name=takajo-${{ github.event.inputs.release_ver }}-mac-aarch64" >> $GITHUB_OUTPUT ;; | |
'macos-13') | |
echo "artifact_name=takajo-${{ github.event.inputs.release_ver }}-mac-x64" >> $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: | | |
upload-all-platforms: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: all-packages | |
pattern: takajo-* | |
merge-multiple: true | |
- name: Upload Artifacts(all-platforms) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hayabusa-${{ 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: takajo-* | |
- run: | | |
ls -lR all-packages | |
cd all-packages | |
for dir in */; do | |
zip -r "${dir%/}.zip" "$dir" | |
done | |
- name: Upload Zip Artifacts(all-packages) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: all-packages | |
path: all-packages/*.zip |