Merge pull request #94 from ALRhub/publish_from_release
Publish from release
This commit is contained in:
commit
f7ccfc808a
26
.github/workflows/ensure-release-tagged.yaml
vendored
Normal file
26
.github/workflows/ensure-release-tagged.yaml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
name: Ensure Tagged Commits on Release
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- release
|
||||
|
||||
jobs:
|
||||
check_tag:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check if base commit of PR is tagged
|
||||
run: |
|
||||
BASE_COMMIT=$(jq -r .pull_request.base.sha < "$GITHUB_EVENT_PATH")
|
||||
TAG=$(git tag --contains $BASE_COMMIT)
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Base commit of PR is not tagged. PRs onto release must be tagged with the version number."
|
||||
exit 1
|
||||
fi
|
||||
echo "Base commit of PR is tagged. Check passed."
|
||||
|
16
.github/workflows/publish-to-pypi.yml
vendored
16
.github/workflows/publish-to-pypi.yml
vendored
@ -2,29 +2,27 @@ name: Publish Python package to PyPI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
branches:
|
||||
- release
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
if: false && startsWith(github.ref, 'refs/tags/') # Only run on tagged commits
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # This fetches all history for all branches and tags
|
||||
|
||||
- name: Verify tag is on master branch
|
||||
- name: Check if commit is tagged
|
||||
run: |
|
||||
TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master')
|
||||
if [ -z "$TAG_IS_ON_MASTER" ]; then
|
||||
echo "Tag is not on the master branch. Cancelling the workflow."
|
||||
TAG=$(git tag --contains HEAD)
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Commit is not tagged. Failing the workflow."
|
||||
exit 1
|
||||
fi
|
||||
echo "Tag is on the master branch. Proceeding with the workflow."
|
||||
echo "Commit is tagged. Proceeding with the workflow."
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
|
52
.github/workflows/publish-to-test-pypi.yml
vendored
52
.github/workflows/publish-to-test-pypi.yml
vendored
@ -1,52 +0,0 @@
|
||||
name: Publish Python package to TestPyPI
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish to TestPyPI
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/') # Only run on tagged commits
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # This fetches all history for all branches and tags
|
||||
|
||||
- name: Verify tag is on master branch
|
||||
run: |
|
||||
TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master')
|
||||
if [ -z "$TAG_IS_ON_MASTER" ]; then
|
||||
echo "Tag is not on the master branch. Cancelling the workflow."
|
||||
exit 1
|
||||
fi
|
||||
echo "Tag is on the master branch. Proceeding with the workflow."
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install pypa/build/setuptools/twine
|
||||
run: >-
|
||||
python3 -m
|
||||
pip install
|
||||
build setuptools twine
|
||||
--user
|
||||
|
||||
- name: Prevent fallback onto setup.py
|
||||
run: rm setup.py
|
||||
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: python3 -m build
|
||||
|
||||
- name: Publish to TestPyPI
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
|
||||
run: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
||||
|
Loading…
Reference in New Issue
Block a user