Skip to content

Test GitHub release #18

Test GitHub release

Test GitHub release #18

Workflow file for this run

name: Release
on:
push:
branches:
- workflow_release
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha'
- 'v[0-9]+.[0-9]+.[0-9]+-beta'
jobs:
build_release:
name: build_release
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
MACOSX_DEPLOYMENT_TARGET: '11.0'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pypa/build
run: python3 -m pip install build
shell: bash
- name: Build a binary wheel and a source tarball
id: build
run: python3 -m build
shell: bash
- name: Upload the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
create_release:
name: create_release
needs: ['build_release']
runs-on: ubuntu-latest
permissions:
# IMPORTANT: mandatory for making GitHub Releases
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs#overview
contents: write
steps:
- name: Download the distribution packages
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: List the distribution packages
run: ls -1 dist/*
shell: bash
- name: Create release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
ref_name='${{ github.ref_name }}'
echo "ref_name: $ref_name"
# is this a test release, or a real release?
if [[ "$ref_name" == 'workflow_release' ]]; then
version='v0.0.0-test'
target='--target "workflow_release"'
else
version="$ref_name"
target=''
fi
echo "version: $version"
echo "target: $target"
# is this a pre-release (-rc*, -alpha, -beta, -test)?
if [[ "$version" == *"-"* ]]; then
prerelease='--prerelease'
else
prerelease=''
fi
echo "prerelease: $prerelease"
date=$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')
echo "date: $date"
gh release create \
"$version" \
dist/* \
--title "$version ($date)" \
$target $prerelease --draft \
--repo '${{ github.repository }}'
shell: bash