[Ver] Update to Alpha3 #26
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 Package to PyPI and TestPyPI | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- mpython/_version.py | |
jobs: | |
create-tag: | |
name: Create tag from new version | |
runs-on: "ubuntu-latest" | |
permissions: | |
contents: write | |
id-token: write | |
outputs: | |
MPYTHON_VERSION: ${{ steps.getversion.outputs.MPYTHON_VERSION }} | |
steps: | |
- name: Check out package | |
uses: actions/checkout@v4 | |
- name: Get package version | |
id: getversion | |
run: | | |
VERSION=$(sed -n 's/^__version__ = "\(.*\)"/\1/p' mpython/_version.py) | |
echo "pyproject.toml version: $VERSION" | |
git config user.name github-actions | |
git config user.email [email protected] | |
MSG=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline) | |
echo "Creating tag $VERSION with message:" | |
echo "$MSG" | |
git tag -a "$VERSION" -m "$MSG" | |
echo "MPYTHON_VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
- name: Publish tags | |
run: git push --tags | |
build: | |
name: Build Package | |
runs-on: ubuntu-latest | |
needs: | |
- create-tag | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install pypa/build | |
run: >- | |
python3 -m | |
pip install | |
build | |
--user | |
- name: Build a binary wheel and a source tarball | |
run: python3 -m build | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: >- | |
Publish Package to PyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/mpython-core | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
github-release: | |
name: >- | |
Sign the Package with Sigstore | |
and upload it to GitHub Release | |
needs: | |
- publish-to-pypi | |
- create-tag | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # IMPORTANT: mandatory for making GitHub Releases | |
id-token: write # IMPORTANT: mandatory for sigstore | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Sign the dists with Sigstore | |
uses: sigstore/[email protected] | |
with: | |
inputs: >- | |
./dist/*.tar.gz | |
./dist/*.whl | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release create ${{ needs.create-tag.outputs.MPYTHON_VERSION }} --repo "$GITHUB_REPOSITORY" --notes "" | |
- name: Upload artifact signatures to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
# Upload to GitHub Release using the `gh` CLI. | |
# `dist/` contains the built packages, and the | |
# sigstore-produced signatures and certificates. | |
run: | | |
gh release upload ${{ needs.create-tag.outputs.MPYTHON_VERSION }} dist/** --repo "$GITHUB_REPOSITORY" | |
publish-to-testpypi: | |
name: Publish Package to TestPyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/mpython-core | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |