-
-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (216 loc) · 8.57 KB
/
semantic-release.yml
File metadata and controls
252 lines (216 loc) · 8.57 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Semantic Release - DISABLED
on:
workflow_dispatch:
permissions:
contents: write # Needed to create releases and push tags
actions: read # Needed to read workflow artifacts
packages: write # Needed for package publishing
id-token: write # Needed for PyPI trusted publishing (optional)
jobs:
release:
name: Semantic Release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_git_tag: ${{ steps.semantic.outputs.new_release_git_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install semantic-release
run: |
npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec
- name: Create semantic-release config
run: |
cat > .releaserc.json << 'EOF'
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo '${nextRelease.version}' > VERSION && sed -i 's/^version = .*/version = \"${nextRelease.version}\"/' pyproject.toml && echo '__version__ = \"${nextRelease.version}\"' > __version__.py && echo '__version_info__ = (${nextRelease.version.split('.').join(', ')})' >> __version__.py"
}
],
[
"@semantic-release/git",
{
"assets": ["CHANGELOG.md", "VERSION", "pyproject.toml", "__version__.py"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
EOF
- name: Run semantic-release
id: semantic
run: |
# Führe semantic-release aus und capture Output
semantic-release --dry-run > semantic-output.txt 2>&1 || true
# Prüfe ob ein Release erstellt werden würde
if grep -q "The next release version is" semantic-output.txt; then
echo "Release would be created, running actual semantic-release"
semantic-release
echo "new_release_published=true" >> $GITHUB_OUTPUT
# Extrahiere Version aus Git Tags
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
VERSION=${LATEST_TAG#v}
echo "new_release_version=$VERSION" >> $GITHUB_OUTPUT
echo "new_release_git_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "✅ Release $VERSION created"
else
echo "No release needed"
echo "new_release_published=false" >> $GITHUB_OUTPUT
echo "new_release_version=" >> $GITHUB_OUTPUT
echo "new_release_git_tag=" >> $GITHUB_OUTPUT
fi
# Debug output
echo "Release published: $(cat $GITHUB_OUTPUT | grep new_release_published || echo 'not set')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-upload:
name: Build and Upload Assets
needs: release
runs-on: ubuntu-latest
if: needs.release.outputs.new_release_published == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.new_release_git_tag }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel setuptools
- name: Build Python packages
run: |
python setup.py sdist bdist_wheel
- name: Create source archive
run: |
VERSION=${{ needs.release.outputs.new_release_version }}
git archive --format=tar.gz --prefix=bash-script-maker-$VERSION/ HEAD > bash-script-maker-$VERSION-source.tar.gz
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.release.outputs.new_release_git_tag }}
files: |
dist/*.whl
dist/*.tar.gz
bash-script-maker-${{ needs.release.outputs.new_release_version }}-source.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-flatpak:
name: Build Flatpak
needs: release
runs-on: ubuntu-latest
if: needs.release.outputs.new_release_published == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.new_release_git_tag }}
- name: Set up Flatpak builder
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Clear Flatpak cache
run: |
rm -rf ~/.cache/flatpak-builder || true
- name: Create build directory and files
run: |
mkdir -p build/flatpak
cp bash_script_maker_flatpak.py build/flatpak/
cp flatpak/org.securebits.bashscriptmaker.appdata.xml build/flatpak/
# Create the correct manifest
cat > build/flatpak/org.securebits.bashscriptmaker.yml << 'EOF'
app-id: org.securebits.bashscriptmaker
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
command: bash-script-maker
finish-args:
- --share=ipc
- --socket=wayland
- --socket=x11
- --socket=pulseaudio
- --device=dri
- --filesystem=home
- --filesystem=host
- --talk-name=org.freedesktop.Notifications
modules:
- name: bash-script-maker
buildsystem: simple
build-commands:
- mkdir -p /app/bin
- cp bash_script_maker_flatpak.py /app/bin/bash-script-maker
- chmod +x /app/bin/bash-script-maker
sources:
- type: dir
path: .
EOF
- name: Build Flatpak
run: |
cd build/flatpak
flatpak-builder --user --install-deps-from=flathub --force-clean --repo=repo build-dir org.securebits.bashscriptmaker.yml
- name: Create Flatpak Bundle
run: |
cd build/flatpak
flatpak build-bundle repo BashScriptMaker-${{ needs.release.outputs.new_release_version }}.flatpak org.securebits.bashscriptmaker
- name: Upload Flatpak to release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.release.outputs.new_release_git_tag }}
files: build/flatpak/BashScriptMaker-${{ needs.release.outputs.new_release_version }}.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: [release, build-and-upload]
runs-on: ubuntu-latest
if: needs.release.outputs.new_release_published == 'true' && !contains(needs.release.outputs.new_release_version, '-')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.new_release_git_tag }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel setuptools
- name: Build packages
run: python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true