|
| 1 | +# LoongSuite Release Workflow |
| 2 | +# |
| 3 | +# This workflow handles the complete LoongSuite release process: |
| 4 | +# |
| 5 | +# 1. PyPI packages (loongsuite-util-genai, loongsuite-distro) |
| 6 | +# 2. GitHub Release (instrumentation-genai/*, instrumentation-loongsuite/* as tar.gz) |
| 7 | +# |
| 8 | +# Trigger: |
| 9 | +# - workflow_dispatch: Manual trigger with version inputs |
| 10 | +# - push tags: Automatic trigger on v* tags |
| 11 | +# |
| 12 | +# Required secrets: |
| 13 | +# - PYPI_API_TOKEN: PyPI API token for publishing (optional, can skip PyPI publish) |
| 14 | +# |
| 15 | +name: LoongSuite Release |
| 16 | + |
| 17 | +run-name: "LoongSuite Release ${{ github.event.inputs.loongsuite_version || github.ref_name }}" |
| 18 | + |
| 19 | +on: |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + loongsuite_version: |
| 23 | + description: 'LoongSuite version (e.g., 0.1.0) - for loongsuite-* packages' |
| 24 | + required: true |
| 25 | + upstream_version: |
| 26 | + description: 'Upstream OTel version (e.g., 0.60b1) - for opentelemetry-* packages in bootstrap_gen.py' |
| 27 | + required: true |
| 28 | + release_notes: |
| 29 | + description: 'Release notes (optional, uses CHANGELOG-loongsuite.md Unreleased if empty)' |
| 30 | + required: false |
| 31 | + skip_pypi: |
| 32 | + description: 'Skip PyPI publish (for testing)' |
| 33 | + type: boolean |
| 34 | + default: false |
| 35 | + push: |
| 36 | + tags: |
| 37 | + - 'v*' |
| 38 | + |
| 39 | +permissions: |
| 40 | + contents: read |
| 41 | + |
| 42 | +env: |
| 43 | + PYTHON_VERSION: '3.11' |
| 44 | + |
| 45 | +jobs: |
| 46 | + # Build all packages |
| 47 | + build: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + outputs: |
| 50 | + loongsuite_version: ${{ steps.version.outputs.loongsuite_version }} |
| 51 | + upstream_version: ${{ steps.version.outputs.upstream_version }} |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Set versions from tag or input |
| 56 | + id: version |
| 57 | + run: | |
| 58 | + if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then |
| 59 | + # Tag-based release: extract version from tag (v0.1.0 -> 0.1.0) |
| 60 | + tag="${GITHUB_REF#refs/tags/}" |
| 61 | + loongsuite_version="${tag#v}" |
| 62 | + # For tag-based release, upstream_version must be set via environment or default |
| 63 | + upstream_version="${UPSTREAM_VERSION:-0.60b1}" |
| 64 | + else |
| 65 | + # Manual release: use inputs |
| 66 | + loongsuite_version="${{ github.event.inputs.loongsuite_version }}" |
| 67 | + upstream_version="${{ github.event.inputs.upstream_version }}" |
| 68 | + fi |
| 69 | +
|
| 70 | + if [[ -z "$loongsuite_version" ]]; then |
| 71 | + echo "ERROR: loongsuite_version is required" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + if [[ -z "$upstream_version" ]]; then |
| 75 | + echo "ERROR: upstream_version is required" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | +
|
| 79 | + echo "loongsuite_version=$loongsuite_version" >> $GITHUB_OUTPUT |
| 80 | + echo "upstream_version=$upstream_version" >> $GITHUB_OUTPUT |
| 81 | + echo "LOONGSUITE_VERSION=$loongsuite_version" >> $GITHUB_ENV |
| 82 | + echo "UPSTREAM_VERSION=$upstream_version" >> $GITHUB_ENV |
| 83 | +
|
| 84 | + echo "LoongSuite version: $loongsuite_version" |
| 85 | + echo "Upstream version: $upstream_version" |
| 86 | +
|
| 87 | + - uses: actions/setup-python@v5 |
| 88 | + with: |
| 89 | + python-version: ${{ env.PYTHON_VERSION }} |
| 90 | + |
| 91 | + - name: Install build dependencies |
| 92 | + run: | |
| 93 | + python -m pip install --upgrade pip |
| 94 | + python -m pip install -r pkg-requirements.txt |
| 95 | +
|
| 96 | + - name: Generate bootstrap_gen.py with versions |
| 97 | + run: | |
| 98 | + python scripts/generate_loongsuite_bootstrap.py \ |
| 99 | + --upstream-version ${{ steps.version.outputs.upstream_version }} \ |
| 100 | + --loongsuite-version ${{ steps.version.outputs.loongsuite_version }} |
| 101 | +
|
| 102 | + echo "Generated bootstrap_gen.py:" |
| 103 | + head -30 loongsuite-distro/src/loongsuite/distro/bootstrap_gen.py |
| 104 | +
|
| 105 | + - name: Build PyPI packages |
| 106 | + run: | |
| 107 | + python scripts/build_loongsuite_package.py \ |
| 108 | + --build-pypi \ |
| 109 | + --version ${{ steps.version.outputs.loongsuite_version }} |
| 110 | +
|
| 111 | + echo "PyPI packages built:" |
| 112 | + ls -la dist/*.whl |
| 113 | +
|
| 114 | + - name: Build GitHub Release packages |
| 115 | + run: | |
| 116 | + python scripts/build_loongsuite_package.py \ |
| 117 | + --build-github-release \ |
| 118 | + --version ${{ steps.version.outputs.loongsuite_version }} |
| 119 | +
|
| 120 | + echo "GitHub Release tar:" |
| 121 | + ls -la dist/*.tar.gz |
| 122 | +
|
| 123 | + - name: Upload PyPI artifacts |
| 124 | + uses: actions/upload-artifact@v4 |
| 125 | + with: |
| 126 | + name: pypi-packages |
| 127 | + path: | |
| 128 | + dist/loongsuite_util_genai-*.whl |
| 129 | + dist/loongsuite_distro-*.whl |
| 130 | +
|
| 131 | + - name: Upload GitHub Release artifact |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: github-release |
| 135 | + path: dist/loongsuite-python-agent-*.tar.gz |
| 136 | + |
| 137 | + # Publish to PyPI |
| 138 | + publish-pypi: |
| 139 | + needs: build |
| 140 | + runs-on: ubuntu-latest |
| 141 | + if: ${{ !inputs.skip_pypi }} |
| 142 | + environment: |
| 143 | + name: pypi |
| 144 | + url: https://pypi.org/project/loongsuite-distro/ |
| 145 | + permissions: |
| 146 | + id-token: write # OIDC publishing |
| 147 | + steps: |
| 148 | + - name: Download PyPI artifacts |
| 149 | + uses: actions/download-artifact@v4 |
| 150 | + with: |
| 151 | + name: pypi-packages |
| 152 | + path: dist/ |
| 153 | + |
| 154 | + - name: Publish to PyPI |
| 155 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 156 | + with: |
| 157 | + # Uses OIDC trusted publishing (no API token needed if configured) |
| 158 | + # Or set PYPI_API_TOKEN secret |
| 159 | + skip-existing: true |
| 160 | + |
| 161 | + # Create GitHub Release |
| 162 | + github-release: |
| 163 | + needs: build |
| 164 | + runs-on: ubuntu-latest |
| 165 | + permissions: |
| 166 | + contents: write # Required for creating releases |
| 167 | + steps: |
| 168 | + - uses: actions/checkout@v4 |
| 169 | + |
| 170 | + - name: Download GitHub Release artifact |
| 171 | + uses: actions/download-artifact@v4 |
| 172 | + with: |
| 173 | + name: github-release |
| 174 | + path: dist/ |
| 175 | + |
| 176 | + - name: Generate release notes |
| 177 | + id: release_notes |
| 178 | + run: | |
| 179 | + LOONGSUITE_VERSION="${{ needs.build.outputs.loongsuite_version }}" |
| 180 | + UPSTREAM_VERSION="${{ needs.build.outputs.upstream_version }}" |
| 181 | +
|
| 182 | + if [[ -n "${{ github.event.inputs.release_notes }}" ]]; then |
| 183 | + echo "${{ github.event.inputs.release_notes }}" > /tmp/release-notes.txt |
| 184 | + else |
| 185 | + # Start with header |
| 186 | + cat > /tmp/release-notes.txt << EOF |
| 187 | + # LoongSuite Python Agent v${LOONGSUITE_VERSION} |
| 188 | +
|
| 189 | + ## Installation |
| 190 | +
|
| 191 | + \`\`\`bash |
| 192 | + pip install loongsuite-distro==${LOONGSUITE_VERSION} |
| 193 | + loongsuite-bootstrap -a install --version ${LOONGSUITE_VERSION} |
| 194 | + \`\`\` |
| 195 | +
|
| 196 | + ## Package Versions |
| 197 | +
|
| 198 | + - loongsuite-* packages: ${LOONGSUITE_VERSION} |
| 199 | + - opentelemetry-* packages: ${UPSTREAM_VERSION} |
| 200 | +
|
| 201 | + --- |
| 202 | +
|
| 203 | + EOF |
| 204 | +
|
| 205 | + # Collect from root CHANGELOG-loongsuite.md |
| 206 | + if [[ -f CHANGELOG-loongsuite.md ]]; then |
| 207 | + echo "## loongsuite-distro" >> /tmp/release-notes.txt |
| 208 | + echo "" >> /tmp/release-notes.txt |
| 209 | + sed -n '/^## \[*Unreleased\]*$/,/^## /p' CHANGELOG-loongsuite.md | sed '/^## /d' >> /tmp/release-notes.txt |
| 210 | + echo "" >> /tmp/release-notes.txt |
| 211 | + fi |
| 212 | +
|
| 213 | + # Collect from instrumentation-loongsuite/*/CHANGELOG.md |
| 214 | + for changelog in instrumentation-loongsuite/*/CHANGELOG.md; do |
| 215 | + if [[ -f "$changelog" ]]; then |
| 216 | + pkg_dir=$(dirname "$changelog") |
| 217 | + pkg_name=$(basename "$pkg_dir") |
| 218 | + unreleased_content=$(sed -n '/^## \[*Unreleased\]*$/,/^## /p' "$changelog" | sed '/^## /d') |
| 219 | + if [[ -n "$unreleased_content" && "$unreleased_content" =~ [^[:space:]] ]]; then |
| 220 | + echo "## $pkg_name" >> /tmp/release-notes.txt |
| 221 | + echo "" >> /tmp/release-notes.txt |
| 222 | + echo "$unreleased_content" >> /tmp/release-notes.txt |
| 223 | + echo "" >> /tmp/release-notes.txt |
| 224 | + fi |
| 225 | + fi |
| 226 | + done |
| 227 | + fi |
| 228 | +
|
| 229 | + echo "Release notes:" |
| 230 | + cat /tmp/release-notes.txt |
| 231 | +
|
| 232 | + - name: Create GitHub release |
| 233 | + env: |
| 234 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 235 | + run: | |
| 236 | + VERSION="${{ needs.build.outputs.loongsuite_version }}" |
| 237 | + gh release create "v${VERSION}" \ |
| 238 | + --title "LoongSuite Python Agent v${VERSION}" \ |
| 239 | + --notes-file /tmp/release-notes.txt \ |
| 240 | + dist/loongsuite-python-agent-${VERSION}.tar.gz |
0 commit comments