Nightly Build #35
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: Nightly Build | |
on: | |
schedule: | |
- cron: '0 0 * * *' # This schedule runs every night at midnight UTC | |
jobs: | |
nightly: | |
runs-on: self-hosted | |
steps: | |
- name: Ensure workspace ownership | |
run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Show working copy revision | |
run: git branch --show-current && git rev-parse HEAD | |
- name: Start builder container | |
run: | | |
TZ=$(readlink -f /etc/localtime | awk -F '/zoneinfo/' '{print $2}') | |
sudo docker rm -f infinity_build && sudo docker run -d --name infinity_build --network=host -e TZ=$TZ -v $PWD:/infinity infiniflow/infinity_build:0.1 | |
- name: Build release version | |
run: sudo docker exec infinity_build bash -c "cd /infinity && rm -fr cmake-build-release && mkdir -p cmake-build-release && cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S /infinity -B /infinity/cmake-build-release && cmake --build /infinity/cmake-build-release" | |
- name: Build RPM and DEB | |
run: sudo docker exec infinity_build bash -c "cd /infinity/cmake-build-release && cpack" | |
- name: Delete Existing nightly build if it exists | |
run: | | |
TAG_NAME=nightly | |
RELEASE_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.MY_GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME \ | |
| jq -r '.id') | |
if [ -n "$RELEASE_ID ]; then | |
curl -X DELETE -H "Authorization: Bearer ${{ secrets.MY_GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID | |
fi | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable | |
with: | |
tag_name: nightly | |
release_name: Nightly build $(date -d @${{ env.GITHUB_RUN_STARTED }} '+%Y-%m-%d %H:%M:%S') | |
body: | | |
# Nightly build $(date -d @${{ env.GITHUB_RUN_STARTED }} '+%Y-%m-%d %H:%M:%S') from ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Upload Binary | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: | | |
cmake-build-release/infinity-*.deb | |
cmake-build-release/infinity-*.rpm | |
cmake-build-release/infinity-*.tar.gz | |
asset_content_type: application/octet-stream |