-
Notifications
You must be signed in to change notification settings - Fork 94
111 lines (93 loc) · 2.99 KB
/
Copy pathpublish-to-pypi.yml
File metadata and controls
111 lines (93 loc) · 2.99 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
104
105
106
107
108
109
110
111
name: Release DockSec
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 2026.5.22.4)'
required: true
type: string
jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.set_version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set version output
id: set_version
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
- name: Update setup.py version
run: |
sed -i 's/version=".*"/version="${{ github.event.inputs.version }}"/' setup.py
- name: Commit and push version update
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add setup.py
# Only commit if there are changes
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: bump version to ${{ github.event.inputs.version }}" && git push)
- name: Create and push tag
run: |
git tag v${{ github.event.inputs.version }}
git push origin v${{ github.event.inputs.version }}
publish-pypi:
needs: update-version
runs-on: ubuntu-latest
environment: pypi-release
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: v${{ needs.update-version.outputs.version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
publish-github-release:
needs: [update-version, publish-pypi]
runs-on: ubuntu-latest
environment: marketplace-release
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: v${{ needs.update-version.outputs.version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.update-version.outputs.version }}
name: Release v${{ needs.update-version.outputs.version }}
generate_release_notes: true
files: |
dist/*.tar.gz
dist/*.whl