|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Runs after CI succeeds on a main-branch push. Releases only when that commit has a |
| 4 | +# vX.Y.Z tag (created by `docks release`). |
| 5 | +on: |
| 6 | + workflow_run: |
| 7 | + workflows: [CI] |
| 8 | + types: [completed] |
| 9 | + |
| 10 | +permissions: |
| 11 | + actions: read |
| 12 | + contents: write |
| 13 | + id-token: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + resolve: |
| 17 | + if: > |
| 18 | + github.event.workflow_run.conclusion == 'success' && |
| 19 | + github.event.workflow_run.event == 'push' && |
| 20 | + github.event.workflow_run.head_branch == 'main' |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + version: ${{ steps.tag.outputs.version }} |
| 24 | + steps: |
| 25 | + - name: Checkout tested commit |
| 26 | + uses: actions/checkout@v7 |
| 27 | + with: |
| 28 | + ref: ${{ github.event.workflow_run.head_sha }} |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Find release tag on commit |
| 32 | + id: tag |
| 33 | + run: | |
| 34 | + TAG=$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || true) |
| 35 | + if [ -z "$TAG" ]; then |
| 36 | + echo "No release tag on ${{ github.event.workflow_run.head_sha }}; skipping release." |
| 37 | + else |
| 38 | + echo "Release tag: $TAG" |
| 39 | + fi |
| 40 | + echo "version=$TAG" >> $GITHUB_OUTPUT |
| 41 | +
|
| 42 | + release: |
| 43 | + needs: resolve |
| 44 | + if: needs.resolve.outputs.version != '' |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + uses: ./.github/workflows/app-release.yml |
| 48 | + with: |
| 49 | + version: ${{ needs.resolve.outputs.version }} |
| 50 | + publish_dir: packages/app/dist |
| 51 | + build_command: npm run build:app |
| 52 | + node_version_file: .nvmrc |
| 53 | + cname: docks.eclipse.dev |
| 54 | + secrets: inherit |
| 55 | + |
| 56 | + deploy-docs: |
| 57 | + needs: release |
| 58 | + if: needs.release.outputs.version != '' |
| 59 | + runs-on: ubuntu-latest |
| 60 | + permissions: |
| 61 | + contents: write |
| 62 | + steps: |
| 63 | + - name: Checkout code |
| 64 | + uses: actions/checkout@v7 |
| 65 | + with: |
| 66 | + ref: ${{ needs.release.outputs.version }} |
| 67 | + |
| 68 | + - name: Set up Node.js |
| 69 | + uses: actions/setup-node@v7 |
| 70 | + with: |
| 71 | + node-version-file: '.nvmrc' |
| 72 | + cache: npm |
| 73 | + |
| 74 | + - name: Install dependencies |
| 75 | + run: npm ci |
| 76 | + |
| 77 | + - name: Build docs |
| 78 | + env: |
| 79 | + DOCKS_DOCS_VERSION: ${{ needs.release.outputs.version }} |
| 80 | + run: npm run docs:build |
| 81 | + |
| 82 | + - name: Deploy docs to GitHub Pages |
| 83 | + uses: peaceiris/actions-gh-pages@v4 |
| 84 | + with: |
| 85 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + publish_dir: docs/.vitepress/dist |
| 87 | + destination_dir: docs |
| 88 | + publish_branch: gh-pages |
| 89 | + keep_files: true |
| 90 | + |
| 91 | + publish-npm: |
| 92 | + needs: release |
| 93 | + if: needs.release.outputs.version != '' |
| 94 | + runs-on: ubuntu-latest |
| 95 | + permissions: |
| 96 | + contents: read |
| 97 | + id-token: write |
| 98 | + steps: |
| 99 | + - name: Checkout code |
| 100 | + uses: actions/checkout@v7 |
| 101 | + with: |
| 102 | + ref: ${{ needs.release.outputs.version }} |
| 103 | + fetch-depth: 0 |
| 104 | + |
| 105 | + - name: Setup Node.js |
| 106 | + uses: actions/setup-node@v7 |
| 107 | + with: |
| 108 | + node-version-file: '.nvmrc' |
| 109 | + registry-url: "https://registry.npmjs.org" |
| 110 | + cache: npm |
| 111 | + |
| 112 | + - name: Install dependencies |
| 113 | + run: npm ci |
| 114 | + |
| 115 | + - name: Update package versions (CI only, not committed) |
| 116 | + run: | |
| 117 | + VERSION="${{ needs.release.outputs.version }}" |
| 118 | + VERSION="${VERSION#v}" |
| 119 | + for pkg in packages/core packages/extension-* packages/create-app packages/cli; do |
| 120 | + [ -d "$pkg" ] && (cd "$pkg" && npm version "$VERSION" --no-git-tag-version) && echo "Updated $pkg to $VERSION" |
| 121 | + done |
| 122 | +
|
| 123 | + - name: Build core package |
| 124 | + run: npm run build |
| 125 | + |
| 126 | + - name: Build extension packages |
| 127 | + run: npm run build:extensions |
| 128 | + |
| 129 | + - name: Run type check |
| 130 | + run: npm run type-check |
| 131 | + continue-on-error: true |
| 132 | + |
| 133 | + - name: Publish core, extensions, create-app, and cli to npm |
| 134 | + run: | |
| 135 | + for pkg in packages/core packages/extension-* packages/create-app packages/cli; do |
| 136 | + if [ -d "$pkg" ]; then |
| 137 | + if grep -q '"private":\s*true' "$pkg/package.json" 2>/dev/null; then |
| 138 | + echo "Skipping $pkg (private)" |
| 139 | + else |
| 140 | + echo "Publishing $pkg..." |
| 141 | + (cd "$pkg" && npm publish --access public --provenance) |
| 142 | + fi |
| 143 | + fi |
| 144 | + done |
0 commit comments