Skip to content

Commit a2fd40a

Browse files
committed
ci: automated release (GitHub action)
* build (currently just for linux amd64) & upload artifact + sha256 * create & publish a release (draft or final, depending on git tag/ref)
1 parent b0cb3c5 commit a2fd40a

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

.github/workflows/release.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Release Standalone Executables
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.py'
7+
- 'requirements.txt'
8+
- '.github/workflows/pyinstaller.yml'
9+
workflow_dispatch:
10+
11+
# Triggers the workflow on push or pull request events
12+
on: [pull_request]
13+
14+
concurrency:
15+
group: build-${{ github.event.pull_request.number || github.ref }}-${{github.workflow}}
16+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
17+
18+
permissions:
19+
contents: write
20+
21+
jobs:
22+
build-linux:
23+
runs-on: ubuntu-22.04
24+
name: Build Linux Executable
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version: 1.24.2
34+
id: go
35+
36+
- name: Build Skaffold from HEAD
37+
run: |
38+
make
39+
echo SKAFFOLD_BINARY=$PWD/out/skaffold >> $GITHUB_ENV
40+
out/skaffold config set --global collect-metrics false
41+
mv out/skaffold skaffold-linux-amd64
42+
sha256sum skaffold > skaffold-linux-amd64.sha256
43+
44+
- name: Get Version from Script and save metadata
45+
run: |
46+
VERSION=$($SKAFFOLD_BINARY version)
47+
echo "$VERSION" | tee skaffold.txt
48+
49+
- name: Upload Linux executable
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: skaffold-linux-amd64
53+
path: |
54+
skaffold-linux-amd64
55+
skaffold-linux-amd64.sha256
56+
skaffold.txt
57+
58+
release:
59+
needs: [build-linux]
60+
runs-on: ubuntu-latest
61+
name: Create Release
62+
steps:
63+
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0 # Fetch all tags and commit history
66+
67+
- name: Download Linux binary
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: skaffold-linux-amd64
71+
path: release
72+
73+
- name: Get Version from Script metadata
74+
id: get_version
75+
run: |
76+
VERSION=$(cat release/skaffold.txt)
77+
echo "version=$VERSION" >> $GITHUB_ENV
78+
79+
- name: Determine Release Type
80+
id: determine_release
81+
run: |
82+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
83+
if git rev-parse "${VERSION}" >/dev/null 2>&1; then
84+
echo "Git tag ${VERSION} already exists. Skipping final release."
85+
echo "final_release=prep" >> $GITHUB_ENV
86+
else
87+
echo "final_release=latest" >> $GITHUB_ENV
88+
fi
89+
else
90+
echo "final_release=draft" >> $GITHUB_ENV
91+
fi
92+
env:
93+
VERSION: ${{ env.version }}
94+
95+
- name: Create GitHub Release
96+
id: publish_release
97+
run: |
98+
if [ "$FINAL_RELEASE" = "latest" ]; then
99+
RELEASE_NAME="${VERSION}"
100+
PUBLISH="--latest"
101+
else
102+
TIMESTAMP=$(date +'%Y%m%d-%H%M%S')
103+
RELEASE_NAME="${VERSION}-${TIMESTAMP}"
104+
if [ "$FINAL_RELEASE" = "draft" ]; then
105+
PUBLISH="--draft"
106+
else
107+
PUBLISH="--prerelease"
108+
fi
109+
fi
110+
gh release create "$RELEASE_NAME" \
111+
--title="Release $RELEASE_NAME" \
112+
--generate-notes \
113+
release/skaffold-linux-amd64 \
114+
release/skaffold-linux-amd64.sha256 \
115+
"$PUBLISH"
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
VERSION: ${{ env.version }}
119+
FINAL_RELEASE: ${{ env.final_release }}

0 commit comments

Comments
 (0)