Skip to content

Commit 43753cc

Browse files
soul2zimateclaude
andcommitted
feat: add early-access build pipeline for main branch
Adds a Stage workflow that automatically produces a rolling GitHub pre-release tagged `early-access` on every push to main, giving users a way to test latest changes without waiting for a formal release. Resolves #397 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 14fce6d commit 43753cc

1 file changed

Lines changed: 134 additions & 0 deletions

File tree

.github/workflows/stage.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
name: Stage
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
paths-ignore:
10+
- ".github/**"
11+
12+
concurrency:
13+
group: stage-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
name: Build project
20+
steps:
21+
- name: Checkout sources
22+
uses: actions/checkout@v6
23+
24+
- name: Set up Java 21
25+
uses: actions/setup-java@v5
26+
with:
27+
distribution: temurin
28+
java-version: 21
29+
cache: maven
30+
31+
- name: Build with Maven
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: mvn package -B -DskipTests -Dskip.junit_platform=true
35+
36+
- name: Upload JAR artifacts
37+
uses: actions/upload-artifact@v7
38+
with:
39+
name: distributions
40+
path: |
41+
./target/trustify-da-java-client-*.jar
42+
!./target/original-*.jar
43+
44+
release:
45+
runs-on: ubuntu-latest
46+
name: Create an early-access release
47+
permissions:
48+
contents: write
49+
needs: build
50+
if: github.repository_owner == 'guacsec'
51+
steps:
52+
- name: Checkout sources
53+
uses: actions/checkout@v6
54+
55+
- name: Download distribution artifacts
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: distributions
59+
path: ./distributions
60+
61+
- name: Check for existing early-access release
62+
id: existing_release
63+
uses: actions/github-script@v7
64+
continue-on-error: true
65+
with:
66+
github-token: ${{ secrets.GITHUB_TOKEN }}
67+
script: |
68+
const repo_name = context.payload.repository.full_name
69+
var response = await github.request('GET /repos/' + repo_name + '/releases/tags/early-access')
70+
// if the request fails (ie 404) the next steps will not occur and the output will not be set
71+
core.setOutput('id', response.data.id)
72+
73+
- name: Delete early-access release if exists
74+
if: ${{ steps.existing_release.outputs.id }}
75+
uses: actions/github-script@v7
76+
with:
77+
github-token: ${{ secrets.GITHUB_TOKEN }}
78+
script: |
79+
const repo_name = context.payload.repository.full_name
80+
await github.request('DELETE /repos/' + repo_name + '/releases/' + ${{ steps.existing_release.outputs.id }})
81+
82+
- name: Delete early-access tag if exists
83+
continue-on-error: true
84+
run: git push --delete origin early-access
85+
86+
# a little pause between deleting the release and creating a new one
87+
# without it, the new release might be a weird release, i.e. a draft release
88+
- name: Sleep 5
89+
run: sleep 5
90+
91+
- name: Create new early-access release
92+
id: new_release
93+
uses: actions/github-script@v7
94+
with:
95+
github-token: ${{ secrets.GITHUB_TOKEN }}
96+
script: |
97+
const repo_name = context.payload.repository.full_name
98+
const response = await github.request('POST /repos/' + repo_name + '/releases', {
99+
tag_name: 'early-access',
100+
name: 'Early-Access',
101+
draft: false,
102+
prerelease: true,
103+
generate_release_notes: true,
104+
make_latest: 'false'
105+
})
106+
core.setOutput('upload_url', response.data.upload_url)
107+
108+
- name: Create SHA256 checksums for the binaries
109+
working-directory: distributions
110+
run: |
111+
short_sha="${{ github.sha }}"
112+
short_sha="${short_sha:0:7}"
113+
# Rename JAR files to include short commit ID and create checksums
114+
for pkg in *.jar; do
115+
[ ! -f "$pkg" ] && continue
116+
new_filename="${pkg%.jar}-${short_sha}.jar"
117+
echo "Renaming $pkg to $new_filename"
118+
mv "$pkg" "$new_filename"
119+
echo "Creating checksum for $new_filename"
120+
sha256sum "$new_filename" > "$new_filename.sha256"
121+
done
122+
123+
- name: Upload packages and checksums as early-access release assets
124+
working-directory: distributions
125+
run: |
126+
for file in *
127+
do
128+
asset_name=$(basename "$file")
129+
upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g")
130+
curl --data-binary @"$file" \
131+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
132+
-H "Content-Type: application/octet-stream" \
133+
"$upload_url"
134+
done

0 commit comments

Comments
 (0)