ci: added workflow for automatic builds #4
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: Autobuild | |
on: push | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
cmake_preset: windows-x86-debug | |
build_conf: Debug | |
- os: ubuntu-latest | |
cmake_preset: linux-x86-debug | |
build_conf: Debug | |
steps: | |
- uses: ilammy/[email protected] | |
if: runner.os == 'Windows' | |
with: | |
arch: ${{ matrix.devenv_arch }} | |
- name: Install dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install gcc-multilib g++-multilib cmake ninja-build git pkg-config tar curl zip unzip tree | |
- name: Install ninja-build tool | |
uses: seanmiddleditch/gha-setup-ninja@v4 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Create build environment | |
run: cmake -E make_directory ${{github.workspace}}/build | |
- name: Configure CMake | |
shell: bash | |
working-directory: ${{github.workspace}}/build | |
run: cmake $GITHUB_WORKSPACE --preset ${{ matrix.cmake_preset }} -DCMAKE_BUILD_TYPE=${{ matrix.build_conf }} | |
- name: Build | |
working-directory: ${{github.workspace}}/build | |
shell: bash | |
run: cmake --build . --config ${{ matrix.build_conf }} | |
- name: Prepare artifacts folder (Linux) | |
if: runner.os == 'Linux' | |
shell: bash | |
run: | | |
tree build/ | |
mkdir artifacts/ | |
mkdir dist/ | |
cp build/${{ matrix.build_conf }}/libnodemod.so dist/ | |
cp deps/node/lib/Release/linux/libnode.so.93 dist/ | |
zip -r ./artifacts/nodemod-${{ matrix.cmake_preset }}.zip ./dist/* | |
- name: Upload artifacts (Linux) | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifact-${{ matrix.cmake_preset }} | |
path: artifacts/* | |
release: | |
name: release-builds | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Check for pull request | |
uses: 8BitJonny/[email protected] | |
id: pr-check | |
with: | |
# Verbose setting SHA when using Pull_Request event trigger to fix #16. (For push even trigger this is not necessary.) | |
sha: ${{ github.event.pull_request.head.sha }} | |
- name: Fetch artifacts | |
if: ${{ always() && github.ref == 'refs/heads/master' && steps.pr-check.outputs.pr_found == 'false' }} | |
uses: actions/[email protected] | |
with: | |
path: artifacts/ | |
- name: Remove old release | |
if: ${{ always() && github.ref == 'refs/heads/master' && steps.pr-check.outputs.pr_found == 'false' }} | |
uses: dev-drprasad/[email protected] | |
with: | |
delete_release: true | |
tag_name: continuous | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Repackage binaries and allow GitHub to process removed release for few seconds | |
if: ${{ always() && github.ref == 'refs/heads/master' && steps.pr-check.outputs.pr_found == 'false' }} | |
continue-on-error: true | |
run: | | |
cd artifacts/ | |
for i in artifact-*; do | |
mv "$i"/* . | |
rm -rf "$i" | |
done | |
ls -R . | |
cd ../ | |
sleep 20s | |
- name: Upload new release | |
if: ${{ always() && github.ref == 'refs/heads/master' && steps.pr-check.outputs.pr_found == 'false' }} | |
uses: softprops/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: artifacts/* | |
tag_name: continuous | |
draft: false | |
prerelease: true | |
name: Nodemod Continuous Build |