Skip to content

Job monitor simplification #892

Job monitor simplification

Job monitor simplification #892

Workflow file for this run

name: Deployment
on:
push:
pull_request:
workflow_dispatch:
inputs:
check-ci:
description: "Require the CI to have passed for this commit"
required: true
default: "yes"
version:
description: "Override the release version number (e.g. 5.0.0a5)"
jobs:
deploy-pypi:
name: PyPI deployment
runs-on: "ubuntu-latest"
if: github.event_name != 'push' || github.repository == 'DIRACGrid/WebAppDIRAC'
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || github.token }}
- run: |
git fetch --prune --unshallow
git config --global user.email "ci@diracgrid.org"
git config --global user.name "DIRACGrid CI"
git clone https://github.com/DIRACGrid/DIRAC.git ../DIRAC
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Installing dependencies
run: |
python -m pip install \
build \
python-dateutil \
pytz \
readme_renderer \
requests \
setuptools_scm \
six
- name: Validate README for PyPI
run: |
python -m readme_renderer README.rst -o /tmp/README.html
- name: Prepare release notes
run: |
set -xeuo pipefail
IFS=$'\n\t'
PREV_VERSION=$(git describe --tags --abbrev=0 --match '*[0-9].[0-9]*' --exclude 'v[0-9]r*' --exclude 'v[0-9][0-9]r*')
REFERENCE_BRANCH=${GITHUB_REF#refs/heads/}
echo "Making release notes for ${REFERENCE_BRANCH} since ${PREV_VERSION}"
../DIRAC/docs/diracdoctools/scripts/dirac-docs-get-release-notes.py \
--token "${{ secrets.GITHUB_TOKEN }}" \
--sinceTag "${PREV_VERSION}" \
--branches "${REFERENCE_BRANCH}" \
--repo "${{ github.repository }}" \
> release.notes.new
cat release.notes.new
- name: Create tag if required
id: check-tag
run: |
set -xeuo pipefail
IFS=$'\n\t'
if [[ "${{ github.repository }}" == "DIRACGrid/WebAppDIRAC" ]]; then
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ "${{ github.event.ref }}" =~ ^refs/heads/(integration|rel-v([5-9]|[1-9][0-9]+)r[0-9]+)$ ]]; then
echo "Will create a real release"
export NEW_VERSION="v${{ github.event.inputs.version }}"
if [[ "${NEW_VERSION}" == "v" ]]; then
NEW_VERSION=v$(python -m setuptools_scm | sed 's@Guessed Version @@g' | sed -E 's@(\.dev|\+g).+@@g')
export NEW_VERSION
fi
echo "Release will be named $NEW_VERSION"
# Validate the version
python -c $'from packaging.version import Version; v = Version('"'$NEW_VERSION'"$')\nif v.is_devrelease:\n raise ValueError(v)'
# Commit the release notes
mv release.notes release.notes.old
{
echo -e "[${NEW_VERSION}]" && \
tail -n +2 release.notes.new | perl -0777pe 's/\n+$/\n\n/' && \
cat release.notes.old;
} > release.notes
git add release.notes
git commit -m "docs: Add release notes for $NEW_VERSION"
git show
# Create the tag
git tag "$NEW_VERSION"
echo "create-release=true" >> $GITHUB_OUTPUT
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
fi
fi
fi
- name: Build distributions
run: |
python -m build
- name: Make release on GitHub
if: steps.check-tag.outputs.create-release == 'true'
run: |
set -e
export NEW_VERSION=${{ steps.check-tag.outputs.new-version }}
echo "Pushing tagged release notes to ${GITHUB_REF#refs/heads/}"
git push "origin" "${GITHUB_REF#refs/heads/}"
echo "Making GitHub release for ${NEW_VERSION}"
../DIRAC/.github/workflows/make_release.py \
--repo="${{ github.repository }}" \
--token="${{ secrets.GITHUB_TOKEN }}" \
--version="${NEW_VERSION}" \
--rev="$(git rev-parse HEAD)" \
--release-notes-fn="release.notes.new"
- name: Publish package on PyPI
if: steps.check-tag.outputs.create-release == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: https://upload.pypi.org/legacy/