chore: update SDK to v0.2.6-beta #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPI | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'pyproject.toml' | |
| workflow_dispatch: | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_publish: ${{ steps.check.outputs.should_publish }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check version change | |
| id: check | |
| run: | | |
| VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "should_publish=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| git show HEAD~1:pyproject.toml > /tmp/old.toml 2>/dev/null || { | |
| echo "should_publish=true" >> $GITHUB_OUTPUT | |
| exit 0 | |
| } | |
| OLD_VERSION=$(grep '^version = ' /tmp/old.toml | sed 's/version = "\(.*\)"/\1/' || echo "") | |
| if [ "$VERSION" != "$OLD_VERSION" ]; then | |
| echo "should_publish=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_publish=false" >> $GITHUB_OUTPUT | |
| fi | |
| publish: | |
| needs: check-version | |
| if: needs.check-version.outputs.should_publish == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/xdk/ | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Build | |
| run: | | |
| pip install build | |
| python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| - name: Create tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${{ needs.check-version.outputs.version }}" -m "v${{ needs.check-version.outputs.version }}" || true | |
| git push origin "v${{ needs.check-version.outputs.version }}" || true | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| generate_release_notes: true |