Skip to content

Commit e4adaaf

Browse files
committed
add auto release for RayCradleDesktop
1 parent beb50ab commit e4adaaf

2 files changed

Lines changed: 166 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ jobs:
105105
done
106106
107107
- name: Upload artifact
108-
uses: actions/upload-artifact@v5
108+
uses: actions/upload-artifact@v6
109109
with:
110110
name: ${{ matrix.artifact }}
111-
path: dist/release/*
111+
path: dist/release/RayCradleDesktop-*
112112
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: Git tag to release
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
17+
env:
18+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
19+
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
20+
RELEASE_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
21+
22+
jobs:
23+
build:
24+
name: Build ${{ matrix.name }}
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- name: Windows
31+
os: windows-latest
32+
goos: windows
33+
goarch: amd64
34+
artifact: RayCradleDesktop-windows-amd64
35+
- name: macOS
36+
os: macos-latest
37+
goos: darwin
38+
goarch: ""
39+
artifact: RayCradleDesktop-macos
40+
- name: Linux AppImage
41+
os: ubuntu-24.04
42+
goos: linux
43+
goarch: amd64
44+
artifact: RayCradleDesktop-linux-amd64-appimage
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v5
49+
with:
50+
ref: ${{ env.RELEASE_REF }}
51+
52+
- name: Set up Go
53+
uses: actions/setup-go@v6
54+
with:
55+
go-version-file: go.mod
56+
cache: true
57+
58+
- name: Install Linux build dependencies
59+
if: runner.os == 'Linux'
60+
shell: bash
61+
run: |
62+
set -euo pipefail
63+
sudo apt-get update
64+
sudo apt-get install -y --no-install-recommends \
65+
build-essential \
66+
curl \
67+
desktop-file-utils \
68+
file \
69+
libgtk-3-dev \
70+
libsoup-3.0-dev \
71+
libwebkit2gtk-4.1-dev \
72+
patchelf \
73+
pkg-config \
74+
zip
75+
sudo apt-get install -y --no-install-recommends libfuse2t64 || \
76+
sudo apt-get install -y --no-install-recommends libfuse2 || true
77+
78+
- name: Test
79+
shell: bash
80+
run: |
81+
set -euo pipefail
82+
if [[ "${RUNNER_OS}" == "Linux" ]]; then
83+
go test -tags gtk3 ./...
84+
else
85+
go test ./...
86+
fi
87+
88+
- name: Build release artifact
89+
shell: bash
90+
env:
91+
RAYCRADLE_VERSION: ${{ env.RELEASE_TAG }}
92+
TARGET_GOOS: ${{ matrix.goos }}
93+
TARGET_GOARCH: ${{ matrix.goarch }}
94+
run: bash scripts/build-release.sh
95+
96+
- name: Verify Windows binary
97+
if: runner.os == 'Windows'
98+
shell: bash
99+
run: |
100+
set -euo pipefail
101+
shopt -s nullglob
102+
exes=(dist/release/*.exe)
103+
if [[ "${#exes[@]}" -eq 0 ]]; then
104+
echo "No Windows .exe was produced in dist/release" >&2
105+
find dist -maxdepth 3 -type f -print >&2 || true
106+
exit 1
107+
fi
108+
for exe in "${exes[@]}"; do
109+
test -s "${exe}"
110+
ls -lh "${exe}"
111+
done
112+
113+
- name: Upload build artifact
114+
uses: actions/upload-artifact@v6
115+
with:
116+
name: ${{ matrix.artifact }}
117+
path: |
118+
dist/release/RayCradleDesktop-*.zip
119+
dist/release/RayCradleDesktop-*.AppImage
120+
if-no-files-found: error
121+
122+
publish:
123+
name: Publish GitHub Release
124+
needs: build
125+
runs-on: ubuntu-latest
126+
127+
steps:
128+
- name: Download build artifacts
129+
uses: actions/download-artifact@v6
130+
with:
131+
path: dist/release
132+
merge-multiple: true
133+
134+
- name: List release assets
135+
shell: bash
136+
run: |
137+
set -euo pipefail
138+
find dist/release -maxdepth 1 -type f -print -exec ls -lh {} \;
139+
140+
- name: Create or update GitHub Release
141+
shell: bash
142+
env:
143+
GH_TOKEN: ${{ github.token }}
144+
GH_REPO: ${{ github.repository }}
145+
run: |
146+
set -euo pipefail
147+
shopt -s nullglob
148+
assets=(dist/release/RayCradleDesktop-*.zip dist/release/RayCradleDesktop-*.AppImage)
149+
if [[ "${#assets[@]}" -eq 0 ]]; then
150+
echo "No RayCradleDesktop .zip or .AppImage release assets found" >&2
151+
exit 1
152+
fi
153+
154+
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
155+
gh release edit "${RELEASE_TAG}" \
156+
--title "RayCradleDesktop ${RELEASE_TAG}" \
157+
--notes "RayCradleDesktop ${RELEASE_TAG}"
158+
gh release upload "${RELEASE_TAG}" "${assets[@]}" --clobber
159+
else
160+
gh release create "${RELEASE_TAG}" "${assets[@]}" \
161+
--verify-tag \
162+
--title "RayCradleDesktop ${RELEASE_TAG}" \
163+
--notes "RayCradleDesktop ${RELEASE_TAG}"
164+
fi

0 commit comments

Comments
 (0)