generated from Justintime50/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (61 loc) · 2.05 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
name: Build & Release
on:
workflow_dispatch:
push:
branches:
- main
- dev
pull_request:
branches:
- dev
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/libretro.py
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Check Out Source
uses: actions/checkout@v4
with:
fetch-depth: 0 # To ensure we have all tags
- name: Install Just
uses: extractions/setup-just@v2
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: setup.py
- name: Install Virtual Environment
run: just install
- name: Validate Formatting
run: just black-check isort-check
- name: Validate Security
run: just bandit
- name: Get Latest Changelog Version
id: changelog
uses: release-flow/[email protected]
with:
command: query
version: latest
- name: Get the Newest Tag
id: newest-tag
run: |
echo "version=`git tag --list "v[0-9]*.[0-9]*.[0-9]*" --sort=-v:refname | head -n1 | cut -c2-`" >> "$GITHUB_OUTPUT"
- name: Build package
run: just build
# Uses the "build" recipe from the justfile
- name: Publish to PyPI
uses: pypa/[email protected]
if: "${{ steps.changelog.outputs.version != steps.newest-tag.outputs.version && github.event_name == 'push' && github.ref == 'refs/heads/main' }}"
- name: Create Release
if: "${{ steps.changelog.outputs.version != steps.newest-tag.outputs.version && github.event_name == 'push' && github.ref == 'refs/heads/main'}}"
uses: softprops/[email protected]
with:
token: ${{ secrets.RELEASE_TOKEN }}
tag_name: "v${{ steps.changelog.outputs.version }}"
body: "${{ steps.changelog.outputs.release-notes }}"