|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + id-token: write |
| 11 | + packages: write |
| 12 | + |
| 13 | +env: |
| 14 | + GH_REPO: AltimateAI/altimate-code |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - uses: oven-sh/setup-bun@v2 |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: bun install |
| 27 | + |
| 28 | + - name: Build all targets |
| 29 | + run: bun run packages/altimate-code/script/build.ts |
| 30 | + env: |
| 31 | + ALTIMATE_CLI_VERSION: ${{ github.ref_name }} |
| 32 | + ALTIMATE_CLI_CHANNEL: latest |
| 33 | + ALTIMATE_CLI_RELEASE: "1" |
| 34 | + GH_REPO: ${{ env.GH_REPO }} |
| 35 | + MODELS_DEV_API_JSON: packages/altimate-code/test/tool/fixtures/models-api.json |
| 36 | + |
| 37 | + - name: Upload build artifacts |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: dist |
| 41 | + path: packages/altimate-code/dist/ |
| 42 | + |
| 43 | + publish-npm: |
| 44 | + name: Publish to npm |
| 45 | + needs: build |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - uses: oven-sh/setup-bun@v2 |
| 51 | + |
| 52 | + - name: Install dependencies |
| 53 | + run: bun install |
| 54 | + |
| 55 | + - name: Download build artifacts |
| 56 | + uses: actions/download-artifact@v4 |
| 57 | + with: |
| 58 | + name: dist |
| 59 | + path: packages/altimate-code/dist/ |
| 60 | + |
| 61 | + - name: Publish to npm |
| 62 | + run: bun run packages/altimate-code/script/publish.ts |
| 63 | + env: |
| 64 | + ALTIMATE_CLI_VERSION: ${{ github.ref_name }} |
| 65 | + ALTIMATE_CLI_CHANNEL: latest |
| 66 | + ALTIMATE_CLI_RELEASE: "1" |
| 67 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 68 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 69 | + GH_REPO: ${{ env.GH_REPO }} |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + |
| 72 | + publish-engine: |
| 73 | + name: Publish engine to PyPI |
| 74 | + needs: build |
| 75 | + runs-on: ubuntu-latest |
| 76 | + environment: pypi |
| 77 | + permissions: |
| 78 | + id-token: write |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - uses: actions/setup-python@v5 |
| 83 | + with: |
| 84 | + python-version: "3.12" |
| 85 | + |
| 86 | + - name: Install build tools |
| 87 | + run: pip install build |
| 88 | + |
| 89 | + - name: Build package |
| 90 | + run: python -m build |
| 91 | + working-directory: packages/altimate-engine |
| 92 | + |
| 93 | + - name: Publish to PyPI |
| 94 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 95 | + with: |
| 96 | + packages-dir: packages/altimate-engine/dist/ |
| 97 | + |
| 98 | + github-release: |
| 99 | + name: Create GitHub Release |
| 100 | + needs: [build, publish-npm] |
| 101 | + runs-on: ubuntu-latest |
| 102 | + permissions: |
| 103 | + contents: write |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + with: |
| 107 | + fetch-depth: 0 |
| 108 | + |
| 109 | + - name: Generate release notes |
| 110 | + id: notes |
| 111 | + run: | |
| 112 | + # Get the previous tag |
| 113 | + PREV_TAG=$(git tag --sort=-version:refname | grep '^v' | head -2 | tail -1) |
| 114 | + CURRENT_TAG=${{ github.ref_name }} |
| 115 | +
|
| 116 | + # Generate changelog from commits between tags |
| 117 | + echo "## What's Changed" > notes.md |
| 118 | + echo "" >> notes.md |
| 119 | +
|
| 120 | + if [ -n "$PREV_TAG" ]; then |
| 121 | + # Categorize commits |
| 122 | + echo "### Features" >> notes.md |
| 123 | + git log ${PREV_TAG}..${CURRENT_TAG} --pretty=format:"- %s (%h)" --grep="^feat" >> notes.md || true |
| 124 | + echo "" >> notes.md |
| 125 | + echo "" >> notes.md |
| 126 | +
|
| 127 | + echo "### Bug Fixes" >> notes.md |
| 128 | + git log ${PREV_TAG}..${CURRENT_TAG} --pretty=format:"- %s (%h)" --grep="^fix" >> notes.md || true |
| 129 | + echo "" >> notes.md |
| 130 | + echo "" >> notes.md |
| 131 | +
|
| 132 | + echo "### Other Changes" >> notes.md |
| 133 | + git log ${PREV_TAG}..${CURRENT_TAG} --pretty=format:"- %s (%h)" --invert-grep --grep="^feat" --grep="^fix" >> notes.md || true |
| 134 | + echo "" >> notes.md |
| 135 | + else |
| 136 | + echo "Initial release" >> notes.md |
| 137 | + fi |
| 138 | +
|
| 139 | + echo "" >> notes.md |
| 140 | + echo "### Install" >> notes.md |
| 141 | + echo '```bash' >> notes.md |
| 142 | + echo "npm install -g altimate-code-ai@${CURRENT_TAG#v}" >> notes.md |
| 143 | + echo "# or" >> notes.md |
| 144 | + echo "brew install altimate/tap/altimate-code" >> notes.md |
| 145 | + echo '```' >> notes.md |
| 146 | +
|
| 147 | + echo "" >> notes.md |
| 148 | + echo "**Full Changelog**: https://github.com/${GH_REPO}/compare/${PREV_TAG}...${CURRENT_TAG}" >> notes.md |
| 149 | + env: |
| 150 | + GH_REPO: ${{ env.GH_REPO }} |
| 151 | + |
| 152 | + - name: Download build artifacts |
| 153 | + uses: actions/download-artifact@v4 |
| 154 | + with: |
| 155 | + name: dist |
| 156 | + path: packages/altimate-code/dist/ |
| 157 | + |
| 158 | + - name: Create GitHub Release |
| 159 | + uses: softprops/action-gh-release@v2 |
| 160 | + with: |
| 161 | + body_path: notes.md |
| 162 | + draft: false |
| 163 | + prerelease: ${{ contains(github.ref_name, '-') }} |
| 164 | + files: | |
| 165 | + packages/altimate-code/dist/*.tar.gz |
| 166 | + packages/altimate-code/dist/*.zip |
| 167 | + env: |
| 168 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments