Skip to content

Commit

Permalink
Test GitHub release
Browse files Browse the repository at this point in the history
  • Loading branch information
tobywf committed Jan 14, 2024
1 parent 95f015e commit 4fa0d08
Showing 1 changed file with 64 additions and 96 deletions.
160 changes: 64 additions & 96 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,125 +1,93 @@
name: Release

on:
push:
branches:
- workflow_release
- workflow_release
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- '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:
name: build
build_release:
name: build_release
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- 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
--user
- name: Checkout repository
uses: actions/checkout@v4

- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/pasteboard/
permissions:
id-token: write
- name: Install pypa/build
run: python3 -m pip install build
shell: bash

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
- 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/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
create_release:
name: create_release
needs: ['build_release']
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
- name: Download the distribution packages
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest
- name: List the distribution packages
run: ls -1 dist/*
shell: bash

environment:
name: testpypi
url: https://pypi.org/project/pasteboard/
- name: Create release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
ref_name='${{ github.ref_name }}'
echo "ref_name: $ref_name"
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
# is this a test release, or a real release?
if [[ "$ref_name" == 'workflow_release' ]]; then
version='v0.0.0-test'
target='--target "${{ github.sha }}"'
else
version="$ref_name"
target=''
fi
echo "version: $version"
echo "target: $target"
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# 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
shell: bash

0 comments on commit 4fa0d08

Please sign in to comment.