|
1
|
name: Publish to PyPI & Docker Hub |
|
2
|
|
|
3
|
on: |
|
4
|
release: |
|
5
|
types: [published] |
|
6
|
|
|
7
|
concurrency: |
|
8
|
group: publish-${{ github.ref }} |
|
9
|
cancel-in-progress: false |
|
10
|
|
|
11
|
permissions: |
|
12
|
contents: write |
|
13
|
|
|
14
|
jobs: |
|
15
|
pypi: |
|
16
|
name: Publish to PyPI |
|
17
|
runs-on: ubuntu-latest |
|
18
|
environment: pypi |
|
19
|
permissions: |
|
20
|
id-token: write |
|
21
|
|
|
22
|
steps: |
|
23
|
- uses: actions/checkout@v4 |
|
24
|
|
|
25
|
- uses: actions/setup-python@v5 |
|
26
|
with: |
|
27
|
python-version: "3.12" |
|
28
|
|
|
29
|
- name: Install build tools |
|
30
|
run: pip install build |
|
31
|
|
|
32
|
- name: Build package |
|
33
|
run: python -m build |
|
34
|
|
|
35
|
- name: Publish to PyPI |
|
36
|
uses: pypa/gh-action-pypi-publish@release/v1 |
|
37
|
|
|
38
|
release-assets: |
|
39
|
name: Upload release archives |
|
40
|
runs-on: ubuntu-latest |
|
41
|
permissions: |
|
42
|
contents: write |
|
43
|
|
|
44
|
steps: |
|
45
|
- uses: actions/checkout@v4 |
|
46
|
|
|
47
|
- uses: actions/setup-python@v5 |
|
48
|
with: |
|
49
|
python-version: "3.12" |
|
50
|
|
|
51
|
- name: Extract version |
|
52
|
id: version |
|
53
|
run: echo "tag=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
|
54
|
|
|
55
|
- name: Build release tarball and zip |
|
56
|
run: | |
|
57
|
VERSION="${{ steps.version.outputs.tag }}" |
|
58
|
|
|
59
|
# Download Python deps into vendor/ |
|
60
|
pip download -r <(python -c " |
|
61
|
import tomllib |
|
62
|
with open('pyproject.toml', 'rb') as f: |
|
63
|
d = tomllib.load(f) |
|
64
|
print('\n'.join(d['project'].get('dependencies', []))) |
|
65
|
") -d vendor/ |
|
66
|
|
|
67
|
# Create archives with source + install.sh + vendored deps |
|
68
|
# Use --warning=no-file-changed to avoid exit code 1 on concurrent writes |
|
69
|
tar czf "fossilrepo-${VERSION}.tar.gz" \ |
|
70
|
--warning=no-file-changed \ |
|
71
|
--transform "s,^,fossilrepo-${VERSION}/," \ |
|
72
|
--exclude='.git' \ |
|
73
|
--exclude='__pycache__' \ |
|
74
|
--exclude='*.pyc' \ |
|
75
|
--exclude='.ruff_cache' \ |
|
76
|
--exclude='node_modules' \ |
|
77
|
--exclude='assets' \ |
|
78
|
. || [[ $? -eq 1 ]] |
|
79
|
|
|
80
|
# Zip version |
|
81
|
mkdir -p "/tmp/fossilrepo-${VERSION}" |
|
82
|
rsync -a --exclude='.git' --exclude='__pycache__' --exclude='*.pyc' \ |
|
83
|
--exclude='.ruff_cache' --exclude='node_modules' --exclude='assets' \ |
|
84
|
. "/tmp/fossilrepo-${VERSION}/" |
|
85
|
cd /tmp && zip -qr "$GITHUB_WORKSPACE/fossilrepo-${VERSION}.zip" "fossilrepo-${VERSION}" |
|
86
|
|
|
87
|
- name: Upload to GitHub Release |
|
88
|
env: |
|
89
|
GH_TOKEN: ${{ github.token }} |
|
90
|
run: | |
|
91
|
VERSION="${{ steps.version.outputs.tag }}" |
|
92
|
gh release upload "${{ github.ref_name }}" \ |
|
93
|
"fossilrepo-${VERSION}.tar.gz" \ |
|
94
|
"fossilrepo-${VERSION}.zip" \ |
|
95
|
--clobber |
|
96
|
|
|
97
|
docker: |
|
98
|
name: Publish to Docker Hub |
|
99
|
runs-on: ubuntu-latest |
|
100
|
|
|
101
|
steps: |
|
102
|
- uses: actions/checkout@v4 |
|
103
|
|
|
104
|
- uses: docker/setup-qemu-action@v3 |
|
105
|
|
|
106
|
- uses: docker/setup-buildx-action@v3 |
|
107
|
|
|
108
|
- uses: docker/login-action@v3 |
|
109
|
with: |
|
110
|
username: ${{ secrets.DOCKERHUB_USERNAME }} |
|
111
|
password: ${{ secrets.DOCKERHUB_TOKEN }} |
|
112
|
|
|
113
|
- name: Extract version from tag |
|
114
|
id: version |
|
115
|
run: echo "tag=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
|
116
|
|
|
117
|
- name: Build and push |
|
118
|
uses: docker/build-push-action@v6 |
|
119
|
with: |
|
120
|
context: . |
|
121
|
platforms: linux/amd64,linux/arm64 |
|
122
|
push: true |
|
123
|
tags: | |
|
124
|
conflicthq/fossilrepo:${{ steps.version.outputs.tag }} |
|
125
|
conflicthq/fossilrepo:latest |
|
126
|
cache-from: type=gha |
|
127
|
cache-to: type=gha,mode=max |
|
128
|
provenance: true |
|
129
|
sbom: true |
|
130
|
|