Repository navigation
139 lines (128 loc) · 4.35 KB
/
Copy pathrelease.yml
File metadata and controls
139 lines (128 loc) · 4.35 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Release
# Publishing a GitHub release (tag vX.Y.Z) ships it everywhere: PyPI first, then
# the Docker Hub image and the Homebrew tap, which both follow the PyPI version.
on:
release:
types: [published]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Check tag matches package version
id: version
env:
TAG: ${{ github.event.release.tag_name }}
run: |
version=$(python -c 'import re; print(re.search(r"__version__ = \"(.+)\"", open("src/gitpulse/__init__.py").read())[1])')
if [ "${TAG#v}" != "$version" ]; then
echo "::error::Release tag $TAG does not match __version__ $version"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- run: python -m pip install build twine
- run: python -m build
- run: twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
pypi:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/gitpulse-analytics/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
docker:
needs: [build, pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to Docker Hardened Images
uses: docker/login-action@v3
with:
registry: dhi.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: fullstackspectrum/gitpulse
# Pre-releases get only their exact version tag.
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=${{ !github.event.release.prerelease }}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ needs.build.outputs.version }}
homebrew:
needs: [build, pypi]
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
# The formula installs the sdist from PyPI, and a new release can take a
# minute or two to show up in the JSON API.
- name: Render formula
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
for attempt in $(seq 1 20); do
if python packaging/homebrew/render_formula.py "$VERSION" > gitpulse.rb; then
exit 0
fi
echo "gitpulse-analytics $VERSION not ready on PyPI yet (attempt $attempt)"
sleep 30
done
echo "::error::gitpulse-analytics $VERSION did not appear on PyPI"
exit 1
- name: Push to tap
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ needs.build.outputs.version }}
run: |
git clone "https://x-access-token:${TAP_TOKEN}@github.com/fullstackspectrum/homebrew-gitpulse.git" tap
mkdir -p tap/Formula
cp gitpulse.rb tap/Formula/gitpulse.rb
cd tap
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/gitpulse.rb
if git diff --cached --quiet; then
echo "Formula already up to date"
else
git commit -m "gitpulse $VERSION"
git push origin HEAD:main
fi