Skip to content

Fix CI (#264)

Fix CI (#264) #211

Workflow file for this run

name: Build & deploy module
on:
push:
branches-ignore:
- "**"
tags:
- "dev/*.*.*-dev.*"
- "rc/*.*.*-rc.*"
- "release/*.*.*"
jobs:
build-server-windows:
name: Build windows server
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Extract version
id: version
shell: bash
run: |
TAG=${GITHUB_REF/refs\/tags\//}
echo "BRANCH=${TAG/\/*}" >> $GITHUB_OUTPUT
echo "VERSION=${TAG/*\/}" >> $GITHUB_OUTPUT
- name: Generate xmake project
shell: bash
run: xmake config -p windows --toolchain=msvc --module-version="${{ steps.version.outputs.BRANCH }}/${{ steps.version.outputs.VERSION }}"
- name: Build xmake project
shell: bash
run: xmake -b server
- name: Copy files
shell: cmd
run: |
mkdir upload\modules
copy build\windows\x64\release\js-module-v2.dll upload\modules
copy build\windows\x64\release\js-module-v2.pdb upload\modules
copy server\deps\nodejs\lib\Release\libnode.dll upload
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: server-windows
path: ./upload
build-server-linux:
name: Build linux server
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Extract version
id: version
shell: bash
run: |
TAG=${GITHUB_REF/refs\/tags\//}
echo "BRANCH=${TAG/\/*}" >> $GITHUB_OUTPUT
echo "VERSION=${TAG/*\/}" >> $GITHUB_OUTPUT
cd deps/cpp-sdk
echo "SDK_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Generate xmake project
shell: bash
run: xmake config --module-version="${{ steps.version.outputs.BRANCH }}/${{ steps.version.outputs.VERSION }}"
- name: Build xmake project
shell: bash
run: xmake -b server
- name: Copy files
run: |
mkdir -p upload/modules
cp build/linux/x86_64/release/libjs-module-v2.so upload/modules
cp server/deps/nodejs/lib/libnode.so upload
echo ${{ steps.version.outputs.SDK_COMMIT }} >> upload/sdk.version
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: server-linux
path: ./upload
build-client-windows:
name: Build windows client
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Extract version
id: version
shell: bash
run: |
TAG=${GITHUB_REF/refs\/tags\//}
echo "BRANCH=${TAG/\/*}" >> $GITHUB_OUTPUT
echo "VERSION=${TAG/*\/}" >> $GITHUB_OUTPUT
- name: Generate xmake project
shell: bash
run: xmake config -p windows --toolchain=msvc --module-version="${{ steps.version.outputs.BRANCH }}/${{ steps.version.outputs.VERSION }}"
- name: Build xmake project
shell: bash
run: xmake -b client
- name: Copy files
shell: cmd
run: |
mkdir upload\modules
copy build\windows\x64\release\js-client-v2.dll upload\modules
copy build\windows\x64\release\js-client-v2.pdb upload\modules
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: client-windows
path: ./upload
build-typings:
name: Upload typings
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Copy files
shell: cmd
run: |
mkdir upload
xcopy types upload /E
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: typings
path: ./upload
release:
name: Upload files to GitHub release
runs-on: ubuntu-20.04
needs: [build-server-windows, build-server-linux, build-client-windows, build-typings]
steps:
- name: Download windows server artifact
uses: actions/download-artifact@v3
with:
name: server-windows
path: dist-server-windows
- name: Download windows client artifact
uses: actions/download-artifact@v3
with:
name: client-windows
path: dist-client-windows
- name: Download linux artifacts
uses: actions/download-artifact@v3
with:
name: server-linux
path: dist-server-linux
- name: Download typing artifact
uses: actions/download-artifact@v3
with:
name: typings
path: dist-typings
- name: Extract version
id: version
shell: bash
run: |
TAG=${GITHUB_REF/refs\/tags\//}
echo "BRANCH=${TAG/\/*}" >> $GITHUB_OUTPUT
echo "VERSION=${TAG/*\/}" >> $GITHUB_OUTPUT
echo "SDK_COMMIT=$(cat dist-server-linux/sdk.version)" >> $GITHUB_OUTPUT
rm dist-server-linux/sdk.version
- name: Zip artifacts
run: |
zip -r js-module-v2-windows-server dist-server-windows
zip -r js-module-v2-windows-client dist-client-windows
zip -r js-module-v2-linux dist-server-linux
zip -r js-module-v2-typings dist-typings
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.version.outputs.BRANCH }}/${{ steps.version.outputs.VERSION }}
prerelease: ${{ contains(steps.version.outputs.BRANCH, 'dev') || contains(steps.version.outputs.BRANCH, 'rc') }}
body: |
SDK version: [${{ steps.version.outputs.SDK_COMMIT }}](https://github.com/altmp/cpp-sdk/commit/${{ steps.version.outputs.SDK_COMMIT }})
- name: Upload windows server artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./js-module-v2-windows-server.zip
asset_name: js-module-v2-windows-server.zip
asset_content_type: application/zip
- name: Upload windows client artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./js-module-v2-windows-client.zip
asset_name: js-module-v2-windows-client.zip
asset_content_type: application/zip
- name: Upload linux artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./js-module-v2-linux.zip
asset_name: js-module-v2-linux.zip
asset_content_type: application/zip
- name: Upload typings artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./js-module-v2-typings.zip
asset_name: js-module-v2-typings.zip
asset_content_type: application/zip
deploy-cdn:
name: Deploy to CDN
runs-on: ubuntu-20.04
needs: [build-server-windows, build-server-linux, build-client-windows, build-typings]
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Cache node_modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}
- name: Download windows server artifact
uses: actions/download-artifact@v3
with:
name: server-windows
path: dist-server-windows
- name: Download linux artifacts
uses: actions/download-artifact@v3
with:
name: server-linux
path: dist-server-linux
- name: Extract version
id: version
shell: bash
run: |
TAG=${GITHUB_REF/refs\/tags\//}
echo "BRANCH=${TAG/\/*}" >> $GITHUB_OUTPUT
echo "VERSION=${TAG/*\/}" >> $GITHUB_OUTPUT
echo "SDK_COMMIT=$(cat dist-server-linux/sdk.version)" >> $GITHUB_OUTPUT
rm dist-server-linux/sdk.version
- name: Install upload tool
run: npm i @altmp/upload-tool@latest [email protected]
- name: Deploy windows server artifacts to CDN
run: npx alt-upload dist-server-windows js-module-v2/$BRANCH/x64_win32 $VERSION $SDK_VERSION
env:
AWS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
CF_CACHE_PURGE_TOKEN: ${{ secrets.CF_CACHE_PURGE_TOKEN }}
CF_CACHE_ZONE_ID: ${{ secrets.CF_CACHE_ZONE_ID }}
CF_CACHE_PURGE_URL: ${{ secrets.CF_CACHE_PURGE_URL }}
BRANCH: ${{ steps.version.outputs.BRANCH }}
VERSION: ${{ steps.version.outputs.VERSION }}
SDK_VERSION: ${{ steps.version.outputs.SDK_VERSION }}
- name: Deploy linux server artifacts to CDN
run: npx alt-upload dist-server-linux js-module-v2/$BRANCH/x64_linux $VERSION $SDK_VERSION
env:
AWS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
CF_CACHE_PURGE_TOKEN: ${{ secrets.CF_CACHE_PURGE_TOKEN }}
CF_CACHE_ZONE_ID: ${{ secrets.CF_CACHE_ZONE_ID }}
CF_CACHE_PURGE_URL: ${{ secrets.CF_CACHE_PURGE_URL }}
BRANCH: ${{ steps.version.outputs.BRANCH }}
VERSION: ${{ steps.version.outputs.VERSION }}
SDK_VERSION: ${{ steps.version.outputs.SDK_VERSION }}
delete-artifacts:
name: Delete artifacts
runs-on: ubuntu-20.04
needs: [release, deploy-cdn]
if: ${{ always() }}
steps:
- name: Delete artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: |
server-windows
client-windows
server-linux
typings