-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (130 loc) · 4.62 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (130 loc) · 4.62 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
name: Release desktop
on:
push:
tags:
- '[0-9]*.*.*'
workflow_dispatch:
concurrency:
group: release-desktop-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
jobs:
# One draft per tag. macOS and Windows only upload files to this release.
prepare-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Create a single draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
if release_json="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}" 2>/dev/null)"; then
release_id="$(printf '%s' "$release_json" | jq -r .id)"
is_draft="$(printf '%s' "$release_json" | jq -r .draft)"
if [ "$is_draft" = "true" ]; then
echo "Draft ${release_id} already exists for ${TAG_NAME}."
exit 0
fi
echo "Published release ${release_id} cannot accept more files. Deleting it (tag stays)."
gh api -X DELETE "repos/${GITHUB_REPOSITORY}/releases/${release_id}"
fi
gh api --method POST "repos/${GITHUB_REPOSITORY}/releases" \
-f tag_name="${TAG_NAME}" \
-f name="Dagr ${TAG_NAME}" \
-f body="Desktop installers for ${TAG_NAME}." \
-F draft=true
echo "Created draft for ${TAG_NAME}."
package:
needs: prepare-release
if: always() && (needs.prepare-release.result == 'success' || needs.prepare-release.result == 'skipped')
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: web
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 20
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: Require version tag
if: github.event_name != 'workflow_dispatch'
shell: bash
env:
TAG_NAME: ${{ github.ref_name }}
run: |
# SemVer 2.0.0 without a v prefix: 1.2.3, 1.2.3-alpha.1, 1.2.3-rc.1+build.5
semver='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
if [[ ! "$TAG_NAME" =~ $semver ]]; then
echo "Tag must be SemVer 2.0.0 without a v prefix (for example 1.2.3, 1.2.3-alpha.1, 1.2.3-rc.1+build.5)."
exit 1
fi
- name: Set version from tag
if: startsWith(github.ref, 'refs/tags/')
shell: bash
env:
TAG_NAME: ${{ github.ref_name }}
run: |
node -e '
const fs = require("fs")
const version = process.env.TAG_NAME.replace(/^v/i, "")
const path = "package.json"
const pkg = JSON.parse(fs.readFileSync(path, "utf8"))
pkg.version = version
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + "\n")
'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Package
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
run: |
pnpm build
pnpm exec electron-builder --publish never
- name: Upload to the draft release
if: startsWith(github.ref, 'refs/tags/')
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
version="${TAG_NAME#v}"
out="release/${version}"
shopt -s nullglob
files=(
"${out}/Dagr_${version}.dmg"
"${out}/Dagr_${version}.zip"
"${out}/Dagr_${version}.exe"
"${out}/Dagr_${version}.dmg.blockmap"
"${out}/Dagr_${version}.zip.blockmap"
"${out}/Dagr_${version}.exe.blockmap"
"${out}/latest-mac.yml"
"${out}/latest.yml"
)
existing=()
for file in "${files[@]}"; do
if [ -f "$file" ]; then
existing+=("$file")
fi
done
if [ "${#existing[@]}" -eq 0 ]; then
echo "No installer files found under ${out}."
ls -la "${out}" || true
exit 1
fi
gh release upload "${TAG_NAME}" "${existing[@]}" --clobber