-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (75 loc) · 2.44 KB
/
release.yml
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
name: Publish release
on:
workflow_dispatch:
push:
tags:
- "202[3-9].[0-9][0-9].[0-9]+"
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+"
defaults:
run:
shell: bash
jobs:
# test:
# uses: ./.github/workflows/pytest.yml
release:
runs-on: ubuntu-latest
environment: release
# needs: test
permissions:
# https://github.com/softprops/action-gh-release#permissions
contents: write
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Install build dependencies
run: pip install build
- name: Build package
run: python -m build
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
if: ${{ contains(github.ref, '-rc') }}
with:
repository_url: https://test.pypi.org/legacy/
print_hash: true
skip_existing: true
verbose: true
- name: Parse version and output Test PyPI URL
id: test-version
if: ${{ contains(github.ref, '-rc') }}
run: |
pip install pyproject.toml
output=$(littlepay -v)
version=${output/littlepay /}
echo "TEST_PYPI_RELEASE_URL=https://test.pypi.org/project/calitp-littlepay/$(version)" > "$GITHUB_OUTPUT"
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
if: ${{ !contains(github.ref, '-rc') }}
with:
print_hash: true
- name: Parse version and output PyPI URL
id: version
if: ${{ !contains(github.ref, '-rc') }}
run: |
pip install pyproject.toml
output=$(littlepay -v)
version=${output/littlepay /}
echo "PYPI_RELEASE_URL=https://pypi.org/project/calitp-littlepay/$(version)" > "$GITHUB_OUTPUT"
- name: Release
uses: softprops/action-gh-release@v1
env:
PYPI_RELEASE_URL: ${{ steps.version.outputs.PYPI_RELEASE_URL }}
with:
files: |
./dist/*.tar.gz
./dist/*.whl
prerelease: ${{ contains(github.ref, '-rc') }}
generate_release_notes: ${{ !contains(github.ref, '-rc') }}
append_body: true
body: $TEST_PYPI_RELEASE_URL