|
| 1 | +# LoongSuite Release Workflow |
| 2 | +# |
| 3 | +# This workflow handles the complete LoongSuite release process: |
| 4 | +# |
| 5 | +# 1. Create release/{version} branch from main |
| 6 | +# 2. Build packages (bootstrap_gen.py, PyPI wheels, GitHub Release tar.gz) |
| 7 | +# 3. Collect changelogs and archive Unreleased sections |
| 8 | +# 4. Commit & push release branch |
| 9 | +# 5. Create GitHub Release |
| 10 | +# 6. Publish to PyPI / Test PyPI |
| 11 | +# 7. Create post-release PR to main (archive changelogs + bump dev versions) |
| 12 | +# |
| 13 | +# The core logic lives in scripts/loongsuite/loongsuite_release.sh, which can also be |
| 14 | +# run locally for the same workflow. |
| 15 | +# |
| 16 | +# Trigger: |
| 17 | +# - workflow_dispatch: Manual trigger with version inputs |
| 18 | +# - push tags: Automatic trigger on v* tags |
| 19 | +# |
| 20 | +# PyPI / Test PyPI configuration: |
| 21 | +# - Production PyPI: Set PYPI_API_TOKEN secret, or configure OIDC trusted publishing on pypi.org |
| 22 | +# - Test PyPI: Set TEST_PYPI_TOKEN secret (pypi-xxx from https://test.pypi.org/manage/account/token/) |
| 23 | +# - Use publish_target: testpypi to publish to Test PyPI instead of production |
| 24 | +# |
| 25 | +# IMPORTANT: Only loongsuite_util_genai-*.whl and loongsuite_distro-*.whl are uploaded to PyPI. |
| 26 | +# loongsuite-python-agent-*.tar.gz is for GitHub Release only and must NOT be uploaded to PyPI. |
| 27 | +# |
| 28 | +name: LoongSuite Release |
| 29 | + |
| 30 | +run-name: "LoongSuite Release ${{ github.event.inputs.loongsuite_version || github.ref_name }}" |
| 31 | + |
| 32 | +on: |
| 33 | + workflow_dispatch: |
| 34 | + inputs: |
| 35 | + loongsuite_version: |
| 36 | + description: 'LoongSuite version (e.g., 0.1.0) - for loongsuite-* packages' |
| 37 | + required: true |
| 38 | + upstream_version: |
| 39 | + description: 'Upstream OTel version (e.g., 0.60b1) - for opentelemetry-* packages in bootstrap_gen.py' |
| 40 | + required: true |
| 41 | + skip_pypi: |
| 42 | + description: 'Skip PyPI publish (for testing)' |
| 43 | + type: boolean |
| 44 | + default: false |
| 45 | + publish_target: |
| 46 | + description: 'Publish target: pypi or testpypi' |
| 47 | + type: choice |
| 48 | + options: |
| 49 | + - pypi |
| 50 | + - testpypi |
| 51 | + default: pypi |
| 52 | + push: |
| 53 | + tags: |
| 54 | + - 'v*' |
| 55 | + |
| 56 | +env: |
| 57 | + PYTHON_VERSION: '3.11' |
| 58 | + |
| 59 | +jobs: |
| 60 | + # Build all packages, create release branch, archive changelogs |
| 61 | + build: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + permissions: |
| 64 | + contents: write |
| 65 | + outputs: |
| 66 | + loongsuite_version: ${{ steps.version.outputs.loongsuite_version }} |
| 67 | + upstream_version: ${{ steps.version.outputs.upstream_version }} |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + with: |
| 71 | + fetch-depth: 0 |
| 72 | + |
| 73 | + - name: Set versions from tag or input |
| 74 | + id: version |
| 75 | + run: | |
| 76 | + if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then |
| 77 | + tag="${GITHUB_REF#refs/tags/}" |
| 78 | + loongsuite_version="${tag#v}" |
| 79 | + upstream_version="${UPSTREAM_VERSION:-0.60b1}" |
| 80 | + else |
| 81 | + loongsuite_version="${{ github.event.inputs.loongsuite_version }}" |
| 82 | + upstream_version="${{ github.event.inputs.upstream_version }}" |
| 83 | + fi |
| 84 | +
|
| 85 | + if [[ -z "$loongsuite_version" ]]; then |
| 86 | + echo "ERROR: loongsuite_version is required" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + if [[ -z "$upstream_version" ]]; then |
| 90 | + echo "ERROR: upstream_version is required" |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | +
|
| 94 | + echo "loongsuite_version=$loongsuite_version" >> $GITHUB_OUTPUT |
| 95 | + echo "upstream_version=$upstream_version" >> $GITHUB_OUTPUT |
| 96 | +
|
| 97 | + echo "LoongSuite version: $loongsuite_version" |
| 98 | + echo "Upstream version: $upstream_version" |
| 99 | +
|
| 100 | + - uses: actions/setup-python@v5 |
| 101 | + with: |
| 102 | + python-version: ${{ env.PYTHON_VERSION }} |
| 103 | + |
| 104 | + - name: Configure git for CI |
| 105 | + run: | |
| 106 | + git config user.name "github-actions[bot]" |
| 107 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 108 | +
|
| 109 | + - name: Run release script |
| 110 | + run: | |
| 111 | + ./scripts/loongsuite/loongsuite_release.sh \ |
| 112 | + --loongsuite-version ${{ steps.version.outputs.loongsuite_version }} \ |
| 113 | + --upstream-version ${{ steps.version.outputs.upstream_version }} \ |
| 114 | + --skip-install \ |
| 115 | + --skip-github-release \ |
| 116 | + --skip-post-release-pr |
| 117 | +
|
| 118 | + - name: Upload PyPI artifacts |
| 119 | + uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: pypi-packages |
| 122 | + path: | |
| 123 | + dist-pypi/loongsuite_util_genai-*.whl |
| 124 | + dist-pypi/loongsuite_distro-*.whl |
| 125 | +
|
| 126 | + - name: Upload GitHub Release artifacts |
| 127 | + uses: actions/upload-artifact@v4 |
| 128 | + with: |
| 129 | + name: github-release |
| 130 | + path: | |
| 131 | + dist/loongsuite-python-agent-*.tar.gz |
| 132 | + dist/release-notes.md |
| 133 | +
|
| 134 | + # Publish to production PyPI |
| 135 | + publish-pypi: |
| 136 | + needs: build |
| 137 | + runs-on: ubuntu-latest |
| 138 | + if: | |
| 139 | + (github.event_name != 'workflow_dispatch' || !inputs.skip_pypi) && |
| 140 | + (github.event_name != 'workflow_dispatch' || github.event.inputs.publish_target != 'testpypi') |
| 141 | + environment: |
| 142 | + name: pypi |
| 143 | + url: https://pypi.org/project/loongsuite-distro/ |
| 144 | + permissions: |
| 145 | + id-token: write |
| 146 | + steps: |
| 147 | + - name: Download PyPI artifacts |
| 148 | + uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + name: pypi-packages |
| 151 | + path: dist/ |
| 152 | + |
| 153 | + - name: Publish to PyPI |
| 154 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 155 | + with: |
| 156 | + skip-existing: true |
| 157 | + |
| 158 | + # Publish to Test PyPI (for testing before production) |
| 159 | + publish-testpypi: |
| 160 | + needs: build |
| 161 | + runs-on: ubuntu-latest |
| 162 | + if: ${{ github.event_name == 'workflow_dispatch' && !inputs.skip_pypi && inputs.publish_target == 'testpypi' }} |
| 163 | + steps: |
| 164 | + - name: Download PyPI artifacts |
| 165 | + uses: actions/download-artifact@v4 |
| 166 | + with: |
| 167 | + name: pypi-packages |
| 168 | + path: dist/ |
| 169 | + |
| 170 | + - name: Publish to Test PyPI |
| 171 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 172 | + with: |
| 173 | + repository-url: https://test.pypi.org/legacy/ |
| 174 | + username: __token__ |
| 175 | + password: ${{ secrets.TEST_PYPI_TOKEN }} |
| 176 | + skip-existing: true |
| 177 | + |
| 178 | + # Create GitHub Release |
| 179 | + github-release: |
| 180 | + needs: build |
| 181 | + runs-on: ubuntu-latest |
| 182 | + permissions: |
| 183 | + contents: write |
| 184 | + steps: |
| 185 | + - name: Download GitHub Release artifacts |
| 186 | + uses: actions/download-artifact@v4 |
| 187 | + with: |
| 188 | + name: github-release |
| 189 | + path: dist/ |
| 190 | + |
| 191 | + - name: Create GitHub release |
| 192 | + env: |
| 193 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 194 | + run: | |
| 195 | + VERSION="${{ needs.build.outputs.loongsuite_version }}" |
| 196 | + gh release create "v${VERSION}" \ |
| 197 | + --title "LoongSuite Python Agent v${VERSION}" \ |
| 198 | + --notes-file dist/release-notes.md \ |
| 199 | + dist/loongsuite-python-agent-${VERSION}.tar.gz |
| 200 | +
|
| 201 | + # Create post-release PR to main (archive changelogs + bump dev versions) |
| 202 | + post-release-pr: |
| 203 | + needs: build |
| 204 | + runs-on: ubuntu-latest |
| 205 | + permissions: |
| 206 | + contents: write |
| 207 | + pull-requests: write |
| 208 | + steps: |
| 209 | + - uses: actions/checkout@v4 |
| 210 | + with: |
| 211 | + ref: main |
| 212 | + fetch-depth: 0 |
| 213 | + |
| 214 | + - uses: actions/setup-python@v5 |
| 215 | + with: |
| 216 | + python-version: ${{ env.PYTHON_VERSION }} |
| 217 | + |
| 218 | + - name: Configure git for CI |
| 219 | + run: | |
| 220 | + git config user.name "github-actions[bot]" |
| 221 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 222 | +
|
| 223 | + - name: Create post-release branch and PR |
| 224 | + env: |
| 225 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 226 | + run: | |
| 227 | + VERSION="${{ needs.build.outputs.loongsuite_version }}" |
| 228 | + BRANCH="post-release/v${VERSION}" |
| 229 | + TODAY=$(date -u +%Y-%m-%d) |
| 230 | +
|
| 231 | + git checkout -b "$BRANCH" |
| 232 | +
|
| 233 | + python scripts/loongsuite/collect_loongsuite_changelog.py \ |
| 234 | + --archive \ |
| 235 | + --version "$VERSION" \ |
| 236 | + --date "$TODAY" |
| 237 | +
|
| 238 | + python scripts/loongsuite/collect_loongsuite_changelog.py \ |
| 239 | + --bump-dev \ |
| 240 | + --version "$VERSION" |
| 241 | +
|
| 242 | + git add -A |
| 243 | + git commit -m "chore: post-release v${VERSION} - archive changelogs & bump dev versions |
| 244 | +
|
| 245 | + - Archive Unreleased changelogs as Version ${VERSION} |
| 246 | + - Bump instrumentation-loongsuite module versions to next dev" |
| 247 | +
|
| 248 | + git push origin "$BRANCH" |
| 249 | +
|
| 250 | + gh pr create \ |
| 251 | + --base main \ |
| 252 | + --head "$BRANCH" \ |
| 253 | + --title "chore: post-release v${VERSION}" \ |
| 254 | + --body "## Post-release updates for v${VERSION} |
| 255 | +
|
| 256 | + - Archive \`Unreleased\` changelog sections as \`Version ${VERSION} (${TODAY})\` |
| 257 | + - Bump \`instrumentation-loongsuite\` module versions to next \`.dev\` |
| 258 | +
|
| 259 | + This PR was auto-generated by the release workflow." |
0 commit comments