Skip to content

Commit

Permalink
Added nightly builds to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 authored Jun 21, 2024
1 parent 594d8a9 commit 5946664
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 4 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_nigthly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build nightly

on:
schedule:
- cron: "44 3 * * *"

permissions:
contents: write

jobs:
tag-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get version from Cargo.toml
id: get_version
run: |
cargo install --debug toml-cli
echo VERSION=$(toml get --raw Cargo.toml package.version) >> $GITHUB_OUTPUT
echo NIGHTLY_TAG=v$(toml get --raw Cargo.toml package.version)-nightly >> $GITHUB_OUTPUT
- name: Delete current nightly release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${{ steps.get_version.outputs.NIGHTLY_TAG }}
RELEASE_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME \
| jq -r '.id')
if [ "$RELEASE_ID" != "null" ]; then
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID
echo "Release deleted"
else
echo "Release not found"
fi
- name: Delete nightly tag
run: |
git fetch origin --tags
git tag -d ${{ steps.get_version.outputs.NIGHTLY_TAG }}
git push origin :refs/tags/${{ steps.get_version.outputs.NIGHTLY_TAG }}
continue-on-error: true

- name: Create and push nightly tag
run: |
git config user.name github-actions
git config user.email [email protected]
git tag ${{ steps.get_version.outputs.NIGHTLY_TAG }}
git push origin ${{ steps.get_version.outputs.NIGHTLY_TAG }}
echo "Succesfully created and pushed tag: ${{ steps.get_version.outputs.NIGHTLY_TAG }}"
47 changes: 43 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
tags:
- "v*.*.*"
workflow_run:
workflows: ["Build nightly"]
types:
- completed

permissions:
packages: write
Expand All @@ -13,8 +17,27 @@ jobs:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout
if: github.event_name == 'workflow_run'
uses: actions/checkout@v4

- name: Get version from Cargo.toml
if: github.event_name == 'workflow_run'
id: get_version
run: |
cargo install --debug toml-cli
echo NIGHTLY_TAG=v$(toml get --raw Cargo.toml package.version)-nightly >> $GITHUB_OUTPUT
- name: Release
if: github.event_name == 'workflow_run'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.NIGHTLY_TAG }}
body: "Release ${{ steps.get_version.outputs.NIGHTLY_TAG }}"

- name: Release
uses: softprops/action-gh-release@v1
if: github.event_name != 'workflow_run'
uses: softprops/action-gh-release@v2

frontend:
name: Build frontend
Expand Down Expand Up @@ -93,13 +116,29 @@ jobs:
name: Build Release ${{ matrix.cpu }} ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract version
id: version
- name: Extract version1
id: version1
if: github.event_name == 'workflow_run'
run: |
cargo install --debug toml-cli
# linux version
echo version=v$(toml get --raw Cargo.toml package.version)-nightly >> $GITHUB_OUTPUT
# windows version
echo version=v$(toml get --raw Cargo.toml package.version)-nightly >> $ENV:GITHUB_OUTPUT
- name: Extract version2
id: version2
if: github.event_name != 'workflow_run'
run: |
echo version=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
- name: Set version
id: version
run: |
echo "version=${{ steps.version1.outputs.version }}${{ steps.version2.outputs.version }}" >> $GITHUB_OUTPUT
- name: Update musl tools
if: matrix.build-with == 'cargo' && matrix.os == 'linux'
run: |
Expand Down

0 comments on commit 5946664

Please sign in to comment.