Repository navigation
94 lines (85 loc) · 2.42 KB
/
Copy pathrelease.yml
File metadata and controls
94 lines (85 loc) · 2.42 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag, for example v1.0.0+3.15.1"
required: true
type: string
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
build:
name: Build Windows x64
uses: ./.github/workflows/build-windows.yml
release:
name: Create draft GitHub release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download installer artifact
uses: actions/download-artifact@v4
with:
name: zcode-windows-x64
path: dist
- name: Resolve and verify tag
id: tag
shell: bash
env:
REQUESTED_TAG: ${{ inputs.tag }}
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag="$REQUESTED_TAG"
else
tag="${GITHUB_REF_NAME}"
fi
version="$(node -p "require('./package.json').version")"
if [ -z "$tag" ]; then
echo "Missing release tag" >&2
exit 1
fi
if [ "$tag" != "v${version}" ]; then
echo "Tag $tag does not match package version $version (expected v${version})" >&2
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "[release] tag=$tag package=$version"
- name: Generate checksums
shell: bash
run: |
set -euo pipefail
cd dist
sha256sum *.exe > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create or update draft release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
shopt -s nullglob
assets=(dist/*.exe dist/*.blockmap dist/*.yml dist/SHA256SUMS.txt)
if [ "${#assets[@]}" -eq 0 ]; then
echo "No release assets found under dist" >&2
exit 1
fi
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" "${assets[@]}" --clobber
else
gh release create "$TAG" "${assets[@]}" \
--title "ZCode $TAG" \
--generate-notes \
--draft
fi