summaryrefslogtreecommitdiffstats
path: root/.github/workflows/nightly.yml
blob: 72bae2a3e03beb49f0a8bbd47a663ec0598f1cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Creates nightly deployment builds for main targets. Note this does not cover package distribution channels,
# such as choco.

name: nightly

on:
  schedule:
    - cron: "0 0 * * *"
  workflow_dispatch:
    inputs:
      isMock:
        description: "Replace with any word other than 'mock' to trigger a non-mock run."
        default: "mock"
        required: false

env:
  CARGO_INCREMENTAL: 0
  CARGO_PROFILE_DEV_DEBUG: 0
  CARGO_HUSKY_DONT_INSTALL_HOOKS: true

jobs:
  # TODO: Add a pre-job check to skip if no change; may want to add something to check if there is a new rust version/week limit of skips?

  initialize-job:
    name: initialize-job
    runs-on: ubuntu-latest
    steps:
      - name: Check if mock
        run: |
          echo "${{ github.event.inputs.isMock }}";
          if [[ -z "${{ github.event.inputs.isMock }}" ]]; then
            echo "This is a scheduled nightly run."
          elif [[ "${{ github.event.inputs.isMock }}" == "mock" ]]; then
            echo "This is a mock run."
          else
            echo "This is NOT a mock run. Watch for the generated files!"
          fi

  build-release:
    needs: [initialize-job]
    uses: ./.github/workflows/build_releases.yml
    with:
      caller: "nightly"
    secrets: inherit

  upload-release:
    name: upload-release
    runs-on: ubuntu-latest
    needs: [build-release]
    steps:
      - name: Get release artifacts
        uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
        with:
          pattern: release-*
          path: release
          merge-multiple: true

      - name: Print out all release files
        run: |
          echo "Generated $(ls ./release | wc -l) files:"
          du -h -d 0 ./release/*

      - name: Delete tag and release
        uses: ClementTsang/delete-tag-and-release@v0.3.1
        if: github.event.inputs.isMock != 'mock'
        with:
          delete_release: true
          tag_name: nightly
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release
        run: sleep 10
        if: github.event.inputs.isMock != 'mock'

      - name: Add all release files to nightly release if not mock
        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # 0.1.15
        if: github.event.inputs.isMock != 'mock'
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          prerelease: true
          tag_name: "nightly"
          draft: false
          fail_on_unmatched_files: true
          files: |
            ./release/*