Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inhibit releases when no changes on code base #3221

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
75 changes: 75 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
push:
branches: [releases]

workflow_dispatch:
inputs:
suffix:
description: 'Release Suffix to append to version info. For eg. devN, a0'
required: false
default: ''

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Check if this commit is already released
id: already_released
run: |
if git tag --contains HEAD | grep -e '^[0-9]\{4\}\.[0-9]\{2\}\.[0-9]\{2\}$' ; then exit 1 ; fi

- name: Set up Python
uses: actions/setup-python@v4
with:
# The release process needs distutils - see Parsl issue #2934
# which was removed from Python 3.12
python-version: '3.11'

- name: Set version info
id: version_setter
run: echo "VERSION=$(date +'%Y.%m.%d')$SUFFIX" >> $GITHUB_OUTPUT
env:
SUFFIX: ${{ inputs.suffix }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install build
- name: Build package
run: |
./tag_and_release.sh update_version
./tag_and_release.sh package
env:
VERSION: ${{ steps.version_setter.outputs.VERSION }}

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
# Set the following to publish to TestPypi instead
# password: ${{ secrets.TESTPYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/

password: ${{ secrets.PYPI_API_TOKEN }}

- name: Mint a tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.version_setter.outputs.VERSION }}
message: "Release version: ${{ steps.version_setter.outputs.VERSION }}"
82 changes: 82 additions & 0 deletions .github/workflows/inhibit-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Inhibit autorelease without core code changes

on:
push:
branches: [ releases ] # Or your designated branch

schedule:
- cron: '42 22 * * MON' # Run every Monday at 22:42

workflow_dispatch:
inputs:
suffix:
description: 'Release Suffix to append to version info. For eg. devN, a0'
required: false
default: ''

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Check if release is warranted
uses: gr2m/[email protected] # Replace with latest version if needed
with:
protected-paths: '**/*.py' # Adjust paths as needed

- name: Set up Python
uses: actions/setup-python@v4
with:
# The release process needs distutils - see Parsl issue #2934 # which was removed from Python 3.12
python-version: '3.11'

- name: Set version info (optional)
id: version_setter
run: echo "VERSION=$(date +'%Y.%m.%d')$SUFFIX" >> $GITHUB_OUTPUT
env:
SUFFIX: ${{ github.event.inputs.suffix }} # Assuming suffix is an input

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install build

- name: Build package
run: |
./tag_and_release.sh update_version
./tag_and_release.sh package
env:
VERSION: ${{ steps.version_setter.outputs.VERSION }}

- name: Publish package (if release is warranted)
run: |
if [[ ${{ steps.release_check.outputs.proceed }} == "true" ]]; then
# Your existing publish package step
echo "Publishing package..."
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
fi

- name: Mint a tag (if release is warranted)
run: |
if [[ ${{ steps.release_check.outputs.proceed }} == "true" ]]; then
# Your existing mint tag step
echo "Minting tag..."
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.version_setter.outputs.VERSION }}
message: "Release version: ${{ steps.version_setter.outputs.VERSION }}"
fi

61 changes: 61 additions & 0 deletions .github/workflows/testci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Upload Python Package

on:
push:
branches:
- releases # Run the job on pushes to the releases branch
schedule:
- cron: '* * * * MON' # Run every Monday at 22:42
workflow_dispatch:
inputs:
suffix:
description: 'Release Suffix to append to version info. For eg. devN, a0'
required: false
default: ''

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Check if this commit is already released
id: already_released
run: |
if git tag --contains HEAD | grep -e '^[0-9]\{4\}\.[0-9]\{2\}\.[0-9]\{2\}$' ; then exit 1 ; fi

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Set version info
id: version_setter
run: echo "VERSION=$(date +'%Y.%m.%d')$SUFFIX" >> $GITHUB_OUTPUT
env:
SUFFIX: ${{ inputs.suffix }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install build

- name: Build package
run: |
./tag_and_release.sh update_version
./tag_and_release.sh package
env:
VERSION: ${{ steps.version_setter.outputs.VERSION }}

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Mint a tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.version_setter.outputs.VERSION }}
message: "Release version: ${{ steps.version_setter.outputs.VERSION }}"
Loading