Merge pull request #14 from dl1998/development #32
This file contains 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 New Version | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REPOSITORY_NAME: action-demo | |
jobs: | |
create-release: | |
name: Create a new release | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.7" | |
- name: Retrieve Release Version | |
id: version | |
run: echo "VERSION=$(python3 setup.py --version)" >> "$GITHUB_ENV" | |
- name: "✏️ Generate release changelog" | |
uses: heinrichreimer/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
futureRelease: "v${{ env.VERSION }}" | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: "v${{ env.VERSION }}" | |
name: "Release v${{ env.VERSION }}" | |
bodyFile: CHANGELOG.md | |
- name: Install pypa/build | |
run: python3 -m pip install build --user | |
- name: Build a binary wheel and a source tarball | |
run: python3 -m build --sdist --wheel --outdir dist/ | |
- name: Publish Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linux-dist | |
path: dist/ | |
publish-library-dev: | |
name: Publish new release on dev | |
needs: ['create-release'] | |
permissions: write-all | |
runs-on: ubuntu-latest | |
environment: | |
name: dev | |
url: "https://test.pypi.org/project/${{ env.REPOSITORY_NAME }}/" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux-dist | |
path: dist/ | |
- name: Publish package distributions to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: "https://test.pypi.org/legacy/" | |
publish-library-prod: | |
name: Publish new release on prod | |
needs: ['create-release', 'publish-library-dev'] | |
permissions: write-all | |
runs-on: ubuntu-latest | |
environment: | |
name: prod | |
url: "https://pypi.org/project/${{ env.REPOSITORY_NAME }}/" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux-dist | |
path: dist/ | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |