|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: # Allow manual trigger |
| 8 | + |
| 9 | +permissions: |
| 10 | + pull-requests: write |
| 11 | + contents: read |
| 12 | + issues: write |
| 13 | + checks: read |
| 14 | + statuses: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + nix: |
| 18 | + name: Wait for Garnix |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 30 |
| 21 | + permissions: |
| 22 | + checks: read |
| 23 | + statuses: read |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Sleep hoping Garnix evaluation will start after |
| 27 | + run: sleep 30 |
| 28 | + - name: Wait for Garnix flake.nix evaluation |
| 29 | + uses: lewagon/wait-on-check-action@v1.5.0 |
| 30 | + with: |
| 31 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 32 | + check-regexp: 'Evaluate flake.nix' |
| 33 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + - name: Wait for Garnix packages |
| 35 | + uses: lewagon/wait-on-check-action@v1.5.0 |
| 36 | + with: |
| 37 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 38 | + check-regexp: 'package.*' |
| 39 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + fail-on-no-checks: false |
| 41 | + - uses: cachix/install-nix-action@v31.10.0 |
| 42 | + with: |
| 43 | + github_access_token: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + extra_nix_config: | |
| 45 | + extra-substituters = https://cache.garnix.io |
| 46 | + extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= |
| 47 | + - uses: DeterminateSystems/magic-nix-cache-action@v13 |
| 48 | + |
| 49 | + prerelease: |
| 50 | + name: Rolling Release |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: nix |
| 53 | + timeout-minutes: 30 |
| 54 | + if: github.ref == 'refs/heads/main' |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + steps: |
| 58 | + - name: Build |
| 59 | + run: nix build |
| 60 | + - name: Publish Rolling Release |
| 61 | + run: | |
| 62 | + DATE=$(date -u +%Y-%m-%d) |
| 63 | + TAG="rolling-$DATE" |
| 64 | + if gh release view "$TAG" >/dev/null 2>&1; then |
| 65 | + echo "Rolling release for $DATE already exists. Skipping." |
| 66 | + else |
| 67 | + gh release list --limit 100 | grep "rolling-" | while read -r line; do |
| 68 | + OLD_TAG=$(echo "$line" | awk '{print $1}') |
| 69 | + OLD_DATE=${OLD_TAG#rolling-} |
| 70 | + if [ "$(date -d "$OLD_DATE" +%s)" -lt "$(date -d "7 days ago" +%s)" ]; then |
| 71 | + gh release delete "$OLD_TAG" --yes --cleanup-tag |
| 72 | + fi |
| 73 | + done |
| 74 | + gh release create "$TAG" "SmartPianoEngine" --title "Rolling $DATE" --notes "Automated rolling release for $DATE" --prerelease |
| 75 | + fi |
| 76 | +
|
| 77 | + release: |
| 78 | + name: Stable Release |
| 79 | + runs-on: ubuntu-latest |
| 80 | + needs: nix |
| 81 | + timeout-minutes: 30 |
| 82 | + if: startsWith(github.ref, 'refs/tags/v') |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + steps: |
| 86 | + - name: Build |
| 87 | + run: nix build |
| 88 | + - name: Publish Stable Release |
| 89 | + run: | |
| 90 | + TAG=${GITHUB_REF#refs/tags/} |
| 91 | + gh release create "$TAG" "SmartPianoEngine" --title "SmartPiano $TAG" --notes "Release $TAG" |
0 commit comments