Skip to content

Commit 8f1ad77

Browse files
committed
No building to app, just create release
1 parent 96a6015 commit 8f1ad77

2 files changed

Lines changed: 14 additions & 273 deletions

File tree

Lines changed: 14 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build & Release Hopkit
1+
name: Create Release
22

33
on:
44
push:
@@ -22,12 +22,13 @@ jobs:
2222

2323
- id: get_version
2424
run: |
25-
VERSION=$(python3 -c 'import json,sys;print(json.load(open("package.json"))["version"])')
25+
VERSION=$(python3 -c 'import json;print(json.load(open("package.json"))["version"])')
2626
echo "version=$VERSION" >> $GITHUB_OUTPUT
2727
2828
- id: get_latest
2929
run: |
30-
TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("tag_name",""))')
30+
TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest \
31+
| python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("tag_name",""))')
3132
echo "tag=$TAG" >> $GITHUB_OUTPUT
3233
3334
- id: compare
@@ -40,146 +41,38 @@ jobs:
4041
echo "build=true" >> $GITHUB_OUTPUT
4142
fi
4243
43-
build:
44-
needs: check-version
45-
if: needs.check-version.outputs.build == 'true'
46-
runs-on: ubuntu-latest
47-
steps:
48-
- uses: actions/checkout@v5
49-
with:
50-
fetch-depth: 0
51-
52-
- name: Cache NW.js and appimagetool
53-
uses: actions/cache@v4
54-
with:
55-
path: |
56-
nwjs-cache
57-
key: nwjs-${{ runner.os }}-${{ hashFiles('package.json') }}-${{ env.NW_VERSION }}
58-
env:
59-
NW_VERSION: v0.108.0
60-
61-
- name: Ensure python3 available
62-
uses: actions/setup-python@v4
63-
with:
64-
python-version: '3.x'
65-
66-
- name: Make build script executable
67-
run: chmod +x ./build.sh
68-
69-
- name: Run build (produces dist/)
70-
env:
71-
NW_VERSION: v0.108.0
72-
SRCDIR: src
73-
run: ./build.sh
74-
75-
- name: Upload dist artifacts
76-
uses: actions/upload-artifact@v4
77-
with:
78-
name: dist-artifacts
79-
path: dist/**
80-
8144
release:
82-
needs: [check-version, build]
45+
needs: check-version
8346
if: needs.check-version.outputs.build == 'true'
8447
runs-on: ubuntu-latest
8548
steps:
8649
- uses: actions/checkout@v5
8750
with:
8851
fetch-depth: 0
8952

90-
- name: Download artifacts
91-
uses: actions/download-artifact@v4
92-
with:
93-
name: dist-artifacts
94-
path: dist
95-
96-
- name: Read displayName & version
53+
- name: Read version
9754
id: meta
9855
run: |
99-
DISPLAY=$(python3 -c 'import json,re;d=json.load(open("package.json"));disp=d.get("displayName", d.get("name","App"));print(re.sub(r"[^A-Za-z0-9._-]","",disp))')
10056
VERSION=$(python3 -c 'import json;print(json.load(open("package.json"))["version"])')
101-
echo "display=$DISPLAY" >> $GITHUB_OUTPUT
10257
echo "version=$VERSION" >> $GITHUB_OUTPUT
10358
10459
- name: Create release
105-
id: create_release
10660
env:
10761
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10862
run: |
10963
VERSION="${{ steps.meta.outputs.version }}"
11064
TAG="v${VERSION}"
111-
# create release using GitHub CLI if available, otherwise use API via curl+jq
65+
COMMIT="${{ github.sha }}"
66+
11267
if command -v gh >/dev/null 2>&1; then
113-
gh release create "${TAG}" --title "${TAG}" --notes "Release ${TAG}" || true
68+
gh release create "$TAG" \
69+
--target "$COMMIT" \
70+
--title "$TAG" \
71+
--notes "Source release $TAG" || true
11472
else
115-
# create minimal release via API (jq used only if available; fallback to raw JSON)
116-
PAYLOAD=$(printf '{"tag_name":"%s","name":"%s"}' "$TAG" "$TAG")
11773
curl -s -X POST \
11874
-H "Authorization: token ${GITHUB_TOKEN}" \
11975
-H "Content-Type: application/json" \
120-
-d "$PAYLOAD" \
121-
"https://api.github.com/repos/${{ github.repository }}/releases" > /tmp/release.json || true
122-
fi
123-
124-
- name: Upload release assets
125-
env:
126-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127-
run: |
128-
VERSION="${{ needs.check-version.outputs.version }}"
129-
TAG="v${VERSION}"
130-
DISPLAY="${{ steps.meta.outputs.display }}"
131-
# fallback if meta didn't set outputs (defensive)
132-
if [ -z "$DISPLAY" ]; then
133-
DISPLAY=$(python3 -c 'import json,re;d=json.load(open("package.json"));disp=d.get("displayName",d.get("name","App"));print(re.sub(r"[^A-Za-z0-9._-]","",disp))')
134-
fi
135-
136-
# get upload_url for the release
137-
UPLOAD_URL=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${TAG}" | python3 -c "import sys,json;d=json.load(sys.stdin);print(d.get('upload_url','').split('{')[0])")
138-
if [ -z "$UPLOAD_URL" ]; then
139-
echo "Could not determine upload_url for release ${TAG}"
140-
exit 1
141-
fi
142-
143-
upload() {
144-
local filepath="$1"
145-
local asset_name="$2"
146-
if [ -f "$filepath" ]; then
147-
echo "Uploading $filepath as $asset_name"
148-
curl -s --fail --show-error --data-binary @"$filepath" \
149-
-H "Authorization: token ${GITHUB_TOKEN}" \
150-
-H "Content-Type: application/octet-stream" \
151-
"${UPLOAD_URL}?name=$(basename "$asset_name")"
152-
else
153-
echo "missing file: $filepath"
154-
fi
155-
}
156-
157-
# Mac: zip the .app and upload as Hopkit-mac.zip
158-
if [ -d "dist/${DISPLAY}.app" ]; then
159-
(cd dist && zip -r -q "${DISPLAY}-mac.zip" "${DISPLAY}.app")
160-
upload "dist/${DISPLAY}-mac.zip" "${DISPLAY}-mac.zip"
161-
else
162-
echo "No mac artifact found for ${DISPLAY}"
163-
fi
164-
165-
# Windows: zip the .exe or existing zip as Hopkit-windows.zip
166-
if [ -f "dist/${DISPLAY}.exe" ]; then
167-
(cd dist && zip -r -q "${DISPLAY}-windows.zip" "${DISPLAY}.exe")
168-
upload "dist/${DISPLAY}-windows.zip" "${DISPLAY}-windows.zip"
169-
elif [ -f "dist/${DISPLAY}-win-${VERSION}.zip" ]; then
170-
mv "dist/${DISPLAY}-win-${VERSION}.zip" "dist/${DISPLAY}-windows.zip"
171-
upload "dist/${DISPLAY}-windows.zip" "${DISPLAY}-windows.zip"
172-
else
173-
echo "No windows artifact found for ${DISPLAY}"
174-
fi
175-
176-
# Linux: zip the AppImage as Hopkit-linux.zip
177-
if [ -f "dist/${DISPLAY}.appimage" ]; then
178-
(cd dist && zip -r -q "${DISPLAY}-linux.zip" "${DISPLAY}.appimage")
179-
upload "dist/${DISPLAY}-linux.zip" "${DISPLAY}-linux.zip"
180-
elif [ -f "dist/${DISPLAY}.AppImage" ]; then
181-
(cd dist && zip -r -q "${DISPLAY}-linux.zip" "${DISPLAY}.AppImage")
182-
upload "dist/${DISPLAY}-linux.zip" "${DISPLAY}-linux.zip"
183-
else
184-
echo "No linux AppImage found for ${DISPLAY}"
76+
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"target_commitish\":\"$COMMIT\"}" \
77+
"https://api.github.com/repos/${{ github.repository }}/releases" || true
18578
fi

build.sh

Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
 (0)