Release version v1.9.4 #95
Workflow file for this run
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: "Publish new release" | |
on: # yamllint disable-line rule:truthy | |
push: | |
tags: | |
- v[0-9]+.* | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
jobs: | |
release: | |
name: Build wheels and release on Pypi | |
runs-on: ubuntu-latest | |
if: >- | |
startsWith(github.ref, 'refs/tags/') | |
|| (github.event_name == 'pull_request' && github.event.pull_request.merged == true | |
&& (startsWith(github.event.pull_request.head.ref, 'release/') | |
|| startsWith(github.event.pull_request.head.ref, 'hotfix/'))) | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Extract version from tag name | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
run: | | |
TAG_NAME="${GITHUB_REF/refs\/tags\//}" | |
VERSION=${TAG_NAME#v} | |
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Extract version from branch name (for release branches) | |
if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/') | |
run: | | |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
VERSION=${BRANCH_NAME#release/} | |
VERSION=${VERSION#v} | |
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Extract version from branch name (for hotfix branches) | |
if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'hotfix/') | |
run: | | |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
VERSION=${BRANCH_NAME#hotfix/} | |
VERSION=${VERSION#v} | |
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Show short log (debug) | |
run: git --no-pager log --oneline -n40 | |
- name: Build wheel | |
run: | | |
if ! git rev-parse v${RELEASE_VERSION} > /dev/null 2>&1; then | |
_added_tag=1 | |
git tag v${RELEASE_VERSION} | |
fi | |
python -m pip install build wheel | |
python -m build --wheel --sdist | |
if [ ${_added_tag:-0} -eq 1 ]; then | |
git tag -d v${RELEASE_VERSION} | |
fi | |
- name: Check metadata | |
run: | | |
python3 -m pip install twine --prefer-binary | |
python3 -m twine check dist/* | |
# Code below inspired from this action: | |
# - uses: taiki-e/create-gh-release-action@v1 | |
# with: | |
# title: cmake-pre-commit-hooks $tag | |
# changelog: CHANGELOG.md | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
env: | |
target: x86_64-unknown-linux-musl | |
source_url: https://github.com/taiki-e/parse-changelog/releases/download | |
parse_changelog_tag: v0.5.1 | |
changelog: CHANGELOG.md | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# https://github.com/taiki-e/parse-changelog | |
curl -LsSf "${source_url}/${parse_changelog_tag}/parse-changelog-${target}.tar.gz" | tar xzf - | |
notes=$(./parse-changelog "${changelog}" "${RELEASE_VERSION}") | |
rm -f ./parse-changelog | |
if [[ "${tag}" =~ ^v?[0-9\.]+-[a-zA-Z_0-9\.-]+(\+[a-zA-Z_0-9\.-]+)?$ ]]; then | |
prerelease="--prerelease" | |
fi | |
gh release create "v${RELEASE_VERSION}" ${prerelease:-} \ | |
--title "cmake-pre-commit-hooks v${RELEASE_VERSION}" \ | |
--notes "${notes:-}" \ | |
dist/* | |
- name: Setup Python for Pypi upload | |
uses: actions/setup-python@v4 | |
- name: Publish standard package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
packages_dir: dist/ |