| 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | version: |
| 7 | description: 'Version' |
| 8 | required: true |
| 9 | |
| 10 | jobs: |
| 11 | release-freezegun: |
| 12 | runs-on: ubuntu-latest |
| 13 | name: Release FreezeGun |
| 14 | permissions: |
| 15 | contents: write |
| 16 | id-token: write |
| 17 | env: |
| 18 | VERSION: 0.0.0 |
| 19 | steps: |
| 20 | - name: Set Env |
| 21 | run: | |
| 22 | echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV |
| 23 | - uses: actions/checkout@v4 |
| 24 | with: |
| 25 | fetch-depth: 0 |
| 26 | - name: Set up Python 3.10 |
| 27 | uses: actions/setup-python@v4 |
| 28 | with: |
| 29 | python-version: "3.10" |
| 30 | - name: Install dependencies |
| 31 | run: | |
| 32 | python -m pip install --upgrade pip |
| 33 | pip install wheel setuptools packaging twine build --upgrade |
| 34 | - name: Verify Tag does not exist |
| 35 | run: | |
| 36 | ! git rev-parse ${{ env.VERSION }} || { echo "Ensure that no tag exists for ${{ env.VERSION }}" ; exit 1; } |
| 37 | - name: Set version number |
| 38 | run: sed -i "s/__version__ =.*/__version__ = '${{ env.VERSION }}'/g" freezegun/__init__.py |
| 39 | - name: Increase patch version number |
| 40 | run: | |
| 41 | git config --local user.email "[email protected]" |
| 42 | git config --local user.name "FreezeGun Admin" |
| 43 | git add freezegun/__init__.py |
| 44 | git commit -m "Increase version number" || echo "Nothing to commit" |
| 45 | git push || echo "Nothing to push" |
| 46 | - name: Build Python |
| 47 | run: python -m build |
| 48 | - name: Publish to PyPI |
| 49 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 50 | - name: Tag version on Github |
| 51 | run: | |
| 52 | git tag ${{ env.VERSION }} |
| 53 | git push origin ${{ env.VERSION }} |
| 54 | - name: Create GitHub release |
| 55 | uses: softprops/action-gh-release@v1 |
| 56 | with: |
| 57 | name: ${{ env.VERSION }} |
| 58 | tag_name: ${{ env.VERSION }} |
| 59 | files: dist/* |