Repository navigation
103 lines (95 loc) · 2.9 KB
/
Copy pathrelease.yml
File metadata and controls
103 lines (95 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Release
# A v* tag builds the sdist and the wheel and attaches them to a GitHub release.
# Publishing to PyPI (trusted publishing, environment "pypi") runs only when the
# repository variable PYPI_PUBLISH is "true". To publish a tag that was released
# before that, run this workflow by hand with the tag.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "An existing release tag, e.g. v0.1.1"
required: true
type: string
permissions:
contents: read
env:
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: refs/tags/${{ env.TAG }}
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Check the tag matches the package version
run: |
version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' flaggr/_version.py)
if [ "v${version}" != "${TAG}" ]; then
echo "::error::Tag ${TAG} doesn't match the package version ${version} (flaggr/_version.py)"
exit 1
fi
- name: Test
env:
PYTHONDONTWRITEBYTECODE: "1"
run: |
python -m pip install -e . pytest
python -m pytest -p no:cacheprovider
- name: Build
run: |
python -m pip install build twine
python -m build
python -m twine check --strict dist/*
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error
github-release:
name: GitHub release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Create the release, or replace its files
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
if gh release view "${TAG}" >/dev/null 2>&1; then
gh release upload "${TAG}" dist/* --clobber
else
gh release create "${TAG}" dist/* --verify-tag --title "${TAG}" --generate-notes
fi
pypi:
name: Publish to PyPI
needs: build
if: vars.PYPI_PUBLISH == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/flaggr/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
skip-existing: true