-
Notifications
You must be signed in to change notification settings - Fork 16
176 lines (160 loc) · 5.38 KB
/
release.yml
File metadata and controls
176 lines (160 loc) · 5.38 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Release Pipeline
# This is the main release workflow that handles everything when you push a version tag
# It builds Python packages, Docker images, publishes to PyPI and ghcr.io, and creates GitHub releases
on:
push:
tags:
- "v*" # Trigger ONLY on version tags
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g., v1.0.0)"
required: true
type: string
jobs:
build-python:
name: Build Python distribution 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install flit
- name: Build package
run: |
flit build
ls -lh dist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-pypi:
name: Publish to PyPI 🐍
needs: build-python
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/gsMap
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
build-docker:
name: Build Docker images 🐳
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Convert repository name to lowercase
id: repo
run: echo "name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo.outputs.name }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ steps.repo.outputs.name }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
create-release:
name: Create GitHub Release 📝
needs: [publish-pypi, build-docker]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Python distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign distributions with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Generate Release Notes
id: release_notes
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "# gsMap ${VERSION}" > release_notes.md
echo "" >> release_notes.md
echo "## 📦 Installation" >> release_notes.md
echo "" >> release_notes.md
echo "### PyPI" >> release_notes.md
echo '```bash' >> release_notes.md
echo "pip install gsMap==${VERSION#v}" >> release_notes.md
echo '```' >> release_notes.md
echo "" >> release_notes.md
echo "### Docker" >> release_notes.md
echo '```bash' >> release_notes.md
echo "docker pull ghcr.io/${{ github.repository }}:${VERSION#v}" >> release_notes.md
echo '```' >> release_notes.md
echo "" >> release_notes.md
echo "## 📋 What's Changed" >> release_notes.md
echo "" >> release_notes.md
echo "See [full changelog](https://github.com/${{ github.repository }}/compare/$(git describe --tags --abbrev=0 ${GITHUB_REF}^)...${VERSION})" >> release_notes.md
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create \
'${{ github.ref_name }}' \
--repo '${{ github.repository }}' \
--title "gsMap ${{ github.ref_name }}" \
--notes-file release_notes.md
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload \
'${{ github.ref_name }}' dist/** \
--repo '${{ github.repository }}'