Debian Codegraph @

.github/workflows/release-nightly.yaml

raw
1 name: Release Nightly
2
3 on:
4 workflow_dispatch:
5 inputs:
6 DRY_RUN:
7 description: "Run in test mode without publishing artifacts"
8 required: false
9 default: false
10 type: boolean
11 FORCE_RELEASE:
12 description: "Skip change detection and force the release"
13 required: false
14 default: false
15 type: boolean
16 schedule:
17 - cron: "0 0 * * *"
18
19 permissions:
20 contents: read # Set default read-only permissions
21
22 jobs:
23 check_changes:
24 name: Check for Code Changes
25 runs-on: ubuntu-latest
26 permissions:
27 actions: read # For querying previous workflow runs via API
28 outputs:
29 has-changes: ${{ steps.check.outputs.has-changes }}
30 steps:
31 - name: Checkout Repository
32 if: ${{ inputs.FORCE_RELEASE != 'true' }}
33 uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
34 with:
35 fetch-depth: 0
36 persist-credentials: false
37
38 - name: Get Last Successful Nightly Release
39 if: ${{ inputs.FORCE_RELEASE != 'true' }}
40 id: last-run
41 env:
42 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 BRANCH: ${{ github.ref_name }}
44 run: |
45 # Find the most recent successful run of this workflow (not failed/cancelled)
46 LAST_NIGHTLY_COMMIT=$(gh api repos/"${{ github.repository }}"/actions/runs | \
47 jq --arg branch "$BRANCH" -r '.workflow_runs[] | select(.status=="completed" and .conclusion=="success" and .path==".github/workflows/release-nightly.yaml" and .head_branch==$branch) | .head_sha' | head -1)
48 echo "last_nightly_commit=$LAST_NIGHTLY_COMMIT" >> "$GITHUB_OUTPUT"
49
50 - name: Check for Changes
51 id: check
52 env:
53 LAST_NIGHTLY_COMMIT: ${{ steps.last-run.outputs.last_nightly_commit }}
54 run: |
55 if [ "${{ inputs.FORCE_RELEASE }}" = "true" ]; then
56 echo "Force release enabled, skipping change detection"
57 echo "has-changes=true" >> "$GITHUB_OUTPUT"
58 exit 0
59 fi
60
61 if [ -z "$LAST_NIGHTLY_COMMIT" ]; then
62 echo "No previous successful nightly run found, proceeding with build"
63 echo "has-changes=true" >> "$GITHUB_OUTPUT"
64 exit 0
65 fi
66
67 # Check if there are any changes in the watched paths since last successful nightly run
68 if ! CHANGED=$(git diff --name-only "$LAST_NIGHTLY_COMMIT" HEAD -- "shoutrrr/**" "pkg/**" "internal/**" shoutrrr.go go.mod go.sum); then
69 echo "git diff failed, treating as changes present"
70 echo "has-changes=true" >> "$GITHUB_OUTPUT"
71 exit 0
72 fi
73
74 if [ -n "$CHANGED" ]; then
75 echo "Detected changes in watched paths:"
76 echo "$CHANGED"
77 echo "has-changes=true" >> "$GITHUB_OUTPUT"
78 else
79 echo "No changes detected in watched paths since last successful nightly run"
80 echo "has-changes=false" >> "$GITHUB_OUTPUT"
81 fi
82
83 test:
84 name: Run Tests
85 needs: [check_changes]
86 if: ${{ needs.check_changes.outputs.has-changes == 'true' }}
87 uses: ./.github/workflows/test.yaml
88 permissions:
89 contents: read # For code checkout
90
91 build:
92 name: Run Build
93 needs: [check_changes, test]
94 if: ${{ needs.check_changes.outputs.has-changes == 'true' }}
95 uses: ./.github/workflows/build.yaml
96 permissions:
97 contents: write # For code checkout and uploading release artifacts
98 packages: write # For pushing images to registries
99 attestations: write # For generating provenance and SBOMs
100 id-token: write # For OIDC auth to Docker Hub and GHCR
101 secrets:
102 DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
103 DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
104 with:
105 ENVIRONMENT: CI-Release
106 BUILD_TYPE: nightly
107 DRY_RUN: ${{ inputs.DRY_RUN || false }}