release #5
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: release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| required: true | |
| default: 'x.y.z' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| checks: | |
| name: Version check | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| id: repo | |
| uses: actions/checkout@v5.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5.6.0 | |
| with: | |
| python-version: 3.13 | |
| - name: Get latest release from pip | |
| id: latestreleased | |
| run: | | |
| PREVIOUS_VERSION=$(python -m pip index versions CodeEntropy | grep "CodeEntropy" | cut -d "(" -f2 | cut -d ")" -f1) | |
| echo "pip_tag=$PREVIOUS_VERSION" >> "$GITHUB_OUTPUT" | |
| echo $PREVIOUS_VERSION | |
| - name: version comparison | |
| id: compare | |
| run: | | |
| pip3 install semver | |
| output=$(pysemver compare ${{ steps.latestreleased.outputs.pip_tag }} ${{ github.event.inputs.version }}) | |
| if [ $output -ge 0 ]; then exit 1; fi | |
| version: | |
| name: prepare ${{ github.event.inputs.version }} | |
| needs: checks | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v5.0.0 | |
| - name: Change version in repo | |
| run: sed -i "s/__version__ =.*/__version__ = \"${{ github.event.inputs.version }}\"/g" CodeEntropy/__init__.py | |
| - name: send PR | |
| id: pr_id | |
| uses: peter-evans/create-pull-request@v7.0.8 | |
| with: | |
| commit-message: Update version to ${{ github.event.inputs.version }} | |
| branch: version-update | |
| title: "Update to version ${{ github.event.inputs.version }}" | |
| body: | | |
| Update version | |
| - Update the __init__.py with new release | |
| - Auto-generated by [CI] | |
| base: main | |
| signoff: false | |
| draft: false | |
| - name: merge PR | |
| run: gh pr merge --merge --delete-branch --auto "${{ steps.pr_id.outputs.pull-request-number }}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| tag: | |
| name: tag release | |
| needs: version | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5.0.0 | |
| with: | |
| ref: main | |
| - name: tag v${{ github.event.inputs.version }} | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git tag ${{ github.event.inputs.version }} | |
| git push origin tag ${{ github.event.inputs.version }} | |
| release: | |
| name: make github release | |
| needs: tag | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: create release | |
| uses: softprops/action-gh-release@v2.3.2 | |
| with: | |
| name: v${{ github.event.inputs.version }} | |
| generate_release_notes: true | |
| tag_name: ${{ github.event.inputs.version }} | |
| pypi: | |
| name: make pypi release | |
| needs: [tag, release] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v5.0.0 | |
| with: | |
| ref: main | |
| - name: Set up Python | |
| uses: actions/setup-python@v5.6.0 | |
| with: | |
| python-version: 3.13 | |
| - name: Install flit | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install flit~=3.9 | |
| - name: Build and publish | |
| run: | | |
| flit publish | |
| env: | |
| FLIT_USERNAME: __token__ | |
| FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |