|
| 1 | +name: Release Legacy (NPM App) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_type: |
| 7 | + description: 'Version bump type' |
| 8 | + required: true |
| 9 | + default: 'prepatch' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - prepatch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + # First job: Prepare production release |
| 21 | + prepare-and-commit-prod: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + new_version: ${{ steps.bump_version.outputs.new_version }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - uses: ./.github/actions/setup-project |
| 31 | + |
| 32 | + - name: Calculate and update production version |
| 33 | + id: bump_version |
| 34 | + run: | |
| 35 | + cd npm-app/release |
| 36 | +
|
| 37 | + # Get current version and bump it |
| 38 | + CURRENT_VERSION=$(bun -e "console.log(require('./package.json').version)") |
| 39 | + echo "Current version: $CURRENT_VERSION" |
| 40 | +
|
| 41 | + # Bump version based on input |
| 42 | + npm version ${{ inputs.version_type }} --preid=legacy --no-git-tag-version |
| 43 | + NEW_VERSION=$(bun -e "console.log(require('./package.json').version)") |
| 44 | +
|
| 45 | + echo "New production version: $NEW_VERSION" |
| 46 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 47 | +
|
| 48 | + - name: Configure git |
| 49 | + run: | |
| 50 | + git config --global user.name "github-actions[bot]" |
| 51 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 52 | +
|
| 53 | + - name: Commit and push version bumpAdd commentMore actions |
| 54 | + run: | |
| 55 | + git stash |
| 56 | + git pull --rebase origin main |
| 57 | + git stash pop |
| 58 | + git add npm-app/release/package.json |
| 59 | + git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}" |
| 60 | + git push |
| 61 | +
|
| 62 | + - name: Create and push production tag |
| 63 | + run: | |
| 64 | + git tag "v${{ steps.bump_version.outputs.new_version }}" |
| 65 | + git push origin "v${{ steps.bump_version.outputs.new_version }}" |
| 66 | +
|
| 67 | + - name: Upload updated package |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: updated-package |
| 71 | + path: npm-app/release/ |
| 72 | + |
| 73 | + build-prod-binaries: |
| 74 | + needs: prepare-and-commit-prod |
| 75 | + uses: ./.github/workflows/npm-app-release-build.yml |
| 76 | + with: |
| 77 | + binary-name: codebuff |
| 78 | + new-version: ${{ needs.prepare-and-commit-prod.outputs.new_version }} |
| 79 | + artifact-name: updated-package |
| 80 | + checkout-ref: ${{ github.sha }} |
| 81 | + env-overrides: '{"NEXT_PUBLIC_CODEBUFF_BACKEND_URL": "manicode-backend.onrender.com", "NEXT_PUBLIC_CB_ENVIRONMENT": "prod"}' |
| 82 | + secrets: inherit |
| 83 | + |
| 84 | + # Create GitHub release with all binaries |
| 85 | + create-prod-release: |
| 86 | + needs: [prepare-and-commit-prod, build-prod-binaries] |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Download all binary artifacts |
| 92 | + uses: actions/download-artifact@v4 |
| 93 | + with: |
| 94 | + path: binaries/ |
| 95 | + |
| 96 | + - name: Download updated package |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: updated-package |
| 100 | + path: npm-app/release/ |
| 101 | + |
| 102 | + - name: Create GitHub Release |
| 103 | + uses: softprops/action-gh-release@v1 |
| 104 | + with: |
| 105 | + tag_name: v${{ needs.prepare-and-commit-prod.outputs.new_version }} |
| 106 | + name: Release v${{ needs.prepare-and-commit-prod.outputs.new_version }} |
| 107 | + prerelease: false |
| 108 | + body: | |
| 109 | + ## Codebuff v${{ needs.prepare-and-commit-prod.outputs.new_version }} |
| 110 | +
|
| 111 | + Binary releases for all supported platforms. |
| 112 | +
|
| 113 | + ### Installation |
| 114 | + ```bash |
| 115 | + npm install -g codebuff |
| 116 | + ``` |
| 117 | +
|
| 118 | + ### Platform Binaries |
| 119 | + - `codebuff-linux-x64.tar.gz` - Linux x64 |
| 120 | + - `codebuff-linux-arm64.tar.gz` - Linux ARM64 |
| 121 | + - `codebuff-darwin-x64.tar.gz` - macOS Intel |
| 122 | + - `codebuff-darwin-arm64.tar.gz` - macOS Apple Silicon |
| 123 | + - `codebuff-win32-x64.tar.gz` - Windows x64 |
| 124 | + files: | |
| 125 | + binaries/*/codebuff-* |
| 126 | + repository: CodebuffAI/codebuff-community |
| 127 | + token: ${{ secrets.CODEBUFF_GITHUB_TOKEN }} |
| 128 | + |
| 129 | + # Publish npm package |
| 130 | + publish-prod-npm: |
| 131 | + needs: [prepare-and-commit-prod, create-prod-release] |
| 132 | + runs-on: ubuntu-latest |
| 133 | + permissions: |
| 134 | + contents: read |
| 135 | + id-token: write |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v4 |
| 138 | + |
| 139 | + - name: Download updated package |
| 140 | + uses: actions/download-artifact@v4 |
| 141 | + with: |
| 142 | + name: updated-package |
| 143 | + path: npm-app/release/ |
| 144 | + |
| 145 | + - name: Set up Node.js for npm publishing |
| 146 | + uses: actions/setup-node@v4 |
| 147 | + with: |
| 148 | + node-version: 20 |
| 149 | + registry-url: https://registry.npmjs.org/ |
| 150 | + |
| 151 | + - name: Publish to npm |
| 152 | + run: | |
| 153 | + cd npm-app/release |
| 154 | + npm publish --access public --tag legacy |
| 155 | + env: |
| 156 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments