|
| 1 | +name: Release Desktop |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - "apps/desktop/**" |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: release-desktop |
| 11 | + cancel-in-progress: false |
| 12 | + |
| 13 | +env: |
| 14 | + SKIP: "false" |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + runs-on: macos-latest |
| 19 | + timeout-minutes: 30 |
| 20 | + permissions: |
| 21 | + contents: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Read version from package.json |
| 28 | + id: version |
| 29 | + run: | |
| 30 | + VERSION=$(node -p "require('./apps/desktop/package.json').version") |
| 31 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 32 | +
|
| 33 | + - name: Check if version already released |
| 34 | + id: check_release |
| 35 | + env: |
| 36 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + run: | |
| 38 | + VERSION="${{ steps.version.outputs.version }}" |
| 39 | + if gh release view "v$VERSION" --repo "${{ github.repository }}" > /dev/null 2>&1; then |
| 40 | + echo "skip=true" >> $GITHUB_OUTPUT |
| 41 | + echo "::warning::Version $VERSION already released — skipping build. Bump the version in apps/desktop/package.json to trigger a new release." |
| 42 | + else |
| 43 | + echo "skip=false" >> $GITHUB_OUTPUT |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Install pnpm |
| 47 | + if: steps.check_release.outputs.skip != 'true' |
| 48 | + uses: pnpm/action-setup@v4 |
| 49 | + |
| 50 | + - name: Setup Node.js |
| 51 | + if: steps.check_release.outputs.skip != 'true' |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: 22 |
| 55 | + cache: pnpm |
| 56 | + |
| 57 | + - name: Install dependencies |
| 58 | + if: steps.check_release.outputs.skip != 'true' |
| 59 | + run: pnpm install --frozen-lockfile |
| 60 | + |
| 61 | + - name: Typecheck |
| 62 | + if: steps.check_release.outputs.skip != 'true' |
| 63 | + run: pnpm -C apps/desktop typecheck |
| 64 | + |
| 65 | + - name: Run tests |
| 66 | + if: steps.check_release.outputs.skip != 'true' |
| 67 | + run: pnpm -C apps/desktop test |
| 68 | + |
| 69 | + - name: Build and publish to GitHub Releases |
| 70 | + if: steps.check_release.outputs.skip != 'true' |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + run: pnpm -C apps/desktop release |
| 74 | + |
| 75 | + - name: Upload DMG as workflow artifact |
| 76 | + if: steps.check_release.outputs.skip != 'true' |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: ClosedLoop-macOS-${{ steps.version.outputs.version }} |
| 80 | + path: apps/desktop/dist-dmg/*.dmg |
| 81 | + if-no-files-found: error |
| 82 | + |
| 83 | + - name: Build Slack message |
| 84 | + if: steps.check_release.outputs.skip != 'true' |
| 85 | + id: slack_message |
| 86 | + run: | |
| 87 | + VERSION="${{ steps.version.outputs.version }}" |
| 88 | + RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/v${VERSION}" |
| 89 | + RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 90 | + MSG=$(printf "New ClosedLoop Desktop build ready\nVersion: %s\nRelease: %s\nArtifact: %s" \ |
| 91 | + "$VERSION" "$RELEASE_URL" "$RUN_URL") |
| 92 | + echo "message<<EOF" >> $GITHUB_OUTPUT |
| 93 | + echo "$MSG" >> $GITHUB_OUTPUT |
| 94 | + echo "EOF" >> $GITHUB_OUTPUT |
| 95 | +
|
| 96 | + - name: Notify Slack |
| 97 | + if: steps.check_release.outputs.skip != 'true' |
| 98 | + continue-on-error: true |
| 99 | + uses: ./.github/actions/slack-notify |
| 100 | + with: |
| 101 | + webhook_url: ${{ secrets.SLACK_GITHUB_REPO_WEBHOOK_URL }} |
| 102 | + message: ${{ steps.slack_message.outputs.message }} |
0 commit comments