| Josh Bleecher Snyder | 7b00c2c | 2025-07-02 12:24:30 -0700 | [diff] [blame] | 1 | name: Release Build (Nightly) |
| 2 | |
| 3 | on: |
| 4 | schedule: |
| 5 | - cron: "47 9 * * *" # 1:47 AM Pacific Time (9:47 UTC) |
| 6 | workflow_dispatch: # Allow manual triggering |
| 7 | |
| 8 | permissions: |
| 9 | contents: write |
| 10 | |
| 11 | jobs: |
| 12 | nightly: |
| Josh Bleecher Snyder | a50a3bf | 2025-07-14 19:40:48 +0000 | [diff] [blame] | 13 | environment: release-build |
| Josh Bleecher Snyder | 7b00c2c | 2025-07-02 12:24:30 -0700 | [diff] [blame] | 14 | runs-on: ubuntu-latest |
| 15 | if: github.ref == 'refs/heads/main' |
| 16 | steps: |
| 17 | - name: Checkout |
| 18 | uses: actions/checkout@v4 |
| 19 | with: |
| 20 | fetch-depth: 0 |
| 21 | |
| 22 | - name: Set up Node.js |
| 23 | uses: actions/setup-node@v4 |
| 24 | with: |
| 25 | node-version: "20" |
| 26 | cache: "npm" |
| 27 | cache-dependency-path: "webui/package-lock.json" |
| 28 | |
| 29 | - uses: actions/setup-go@v5 |
| 30 | with: |
| 31 | go-version-file: "${{ inputs.working-directory || '.'}}/go.mod" |
| 32 | cache: true |
| 33 | |
| Josh Bleecher Snyder | 5e97dfc | 2025-07-11 18:14:07 +0000 | [diff] [blame] | 34 | - name: Install selfupdatectl |
| 35 | run: go install github.com/fynelabs/selfupdate/cmd/selfupdatectl@v0.2.1 |
| 36 | |
| Josh Bleecher Snyder | 5e97dfc | 2025-07-11 18:14:07 +0000 | [diff] [blame] | 37 | |
| Josh Bleecher Snyder | 7b00c2c | 2025-07-02 12:24:30 -0700 | [diff] [blame] | 38 | - name: Check for changes since last tag |
| 39 | id: check_changes |
| 40 | run: | |
| 41 | git fetch --tags --force |
| 42 | # find latest nightly tag that looks like nightly/v0.0.N |
| 43 | latest_nightly=$(git tag -l "nightly/v0.0.*" --sort=-v:refname | head -n1) |
| 44 | if [ -z "$latest_nightly" ]; then |
| 45 | echo "has_changes=true" >> $GITHUB_OUTPUT |
| 46 | echo "tag=v0.0.1" >> $GITHUB_OUTPUT |
| 47 | echo "nightly_tag=nightly/v0.0.1" >> $GITHUB_OUTPUT |
| 48 | else |
| 49 | echo "Latest nightly tag is $latest_nightly" |
| 50 | # Check if there are any new commits since the last nightly tag |
| 51 | changes=$(git log $latest_nightly..HEAD --oneline) |
| 52 | if [ -z "$changes" ]; then |
| 53 | echo "No new changes since last nightly tag, skipping nightly build" |
| 54 | echo "has_changes=false" >> $GITHUB_OUTPUT |
| 55 | else |
| 56 | echo "Changes found since last nightly tag:" |
| 57 | echo "$changes" |
| 58 | echo "has_changes=true" >> $GITHUB_OUTPUT |
| 59 | # Extract N from nightly/v0.0.N and increment |
| 60 | version_part="${latest_nightly#nightly/v0.0.}" |
| 61 | new_n=$((version_part + 1)) |
| 62 | new_tag="v0.0.${new_n}" |
| 63 | new_nightly_tag="nightly/v0.0.${new_n}" |
| 64 | echo "tag=$new_tag" >> $GITHUB_OUTPUT |
| 65 | echo "nightly_tag=$new_nightly_tag" >> $GITHUB_OUTPUT |
| 66 | fi |
| 67 | fi |
| 68 | |
| 69 | - name: Create and push nightly git tag |
| 70 | if: steps.check_changes.outputs.has_changes == 'true' |
| 71 | env: |
| 72 | TAG: ${{ steps.check_changes.outputs.tag }} |
| 73 | NIGHTLY_TAG: ${{ steps.check_changes.outputs.nightly_tag }} |
| 74 | run: | |
| 75 | git config user.name "Sketch Nightly Bot" |
| 76 | git config user.email "hello@sketch.dev" |
| 77 | git tag -a "$TAG" -m "Nightly build $TAG" |
| 78 | git tag -a "$NIGHTLY_TAG" -m "Nightly build tracking tag for $TAG" |
| 79 | git push origin "$TAG" |
| 80 | git push origin "$NIGHTLY_TAG" |
| 81 | |
| 82 | - name: Run GoReleaser (Nightly) |
| 83 | if: steps.check_changes.outputs.has_changes == 'true' |
| 84 | uses: goreleaser/goreleaser-action@v4 |
| 85 | with: |
| 86 | version: latest |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 87 | # because our builds aren't hermetic, we must build serially |
| 88 | args: release --clean --parallelism 1 |
| Josh Bleecher Snyder | 7b00c2c | 2025-07-02 12:24:30 -0700 | [diff] [blame] | 89 | env: |
| 90 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| Josh Bleecher Snyder | a50a3bf | 2025-07-14 19:40:48 +0000 | [diff] [blame] | 91 | SELFUPDATE_SIGNING_KEY: ${{ secrets.SELFUPDATE_ED25519_SIGNING_KEY }} |
| Josh Bleecher Snyder | b58bbf3 | 2025-07-16 18:33:34 +0000 | [diff] [blame] | 92 | HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} |
| Josh Bleecher Snyder | 7b00c2c | 2025-07-02 12:24:30 -0700 | [diff] [blame] | 93 | |
| David Crawshaw | b80db9c | 2025-07-12 01:20:36 +0000 | [diff] [blame] | 94 | |
| Josh Bleecher Snyder | 5e97dfc | 2025-07-11 18:14:07 +0000 | [diff] [blame] | 95 | |
| Josh Bleecher Snyder | a50a3bf | 2025-07-14 19:40:48 +0000 | [diff] [blame] | 96 | |