diff --git a/.github/workflows/build_nigthly.yml b/.github/workflows/build_nigthly.yml new file mode 100644 index 00000000..f5a7971b --- /dev/null +++ b/.github/workflows/build_nigthly.yml @@ -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 github-actions@github.com + 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 }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 710de94a..a32c7cb9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,10 @@ on: push: tags: - "v*.*.*" + workflow_run: + workflows: ["Build nightly"] + types: + - completed permissions: packages: write @@ -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 @@ -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: |