Repository navigation
126 lines (120 loc) · 5.33 KB
/
Copy pathrelease.yml
File metadata and controls
126 lines (120 loc) · 5.33 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
name: Release
# Builds every platform's installers and the updates installed apps fetch,
# signed with the MYGO_UPDATER_PRIVATE_KEY secret (docs/updates.md). A
# pushed tag v<version> uploads them to a draft release, to check and
# publish by hand: apps update once it is published. A run started by hand
# keeps them as the run's artifacts, publishing nothing. Publishing the release
# posts its changelog to the Discord server, once (the announce job).
on:
push:
tags: ['v*']
workflow_dispatch:
release:
types: [published]
permissions:
contents: write # the draft release, and the uploads to it
jobs:
draft-release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: The tag names the app's version
run: test "$GITHUB_REF_NAME" = "v$(jq -r .version cmd/enowx/mygo.json)"
- name: The changelog has the version
run: grep -q "^## \[\?$(jq -r .version cmd/enowx/mygo.json)\]\?" CHANGELOG.md
- name: Create the draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
--draft --verify-tag --title "enowX ${GITHUB_REF_NAME#v}" --generate-notes
fi
build:
needs: draft-release
# Runs by hand too, when there is no draft to wait for.
if: ${{ github.event_name != 'release' && !cancelled() && (needs.draft-release.result == 'success' || needs.draft-release.result == 'skipped') }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Disk images and signing need macOS; MyGo needs no cgo, so
# Ubuntu builds Windows' as well as Linux's.
- { name: macOS, os: macos-latest, platform: darwin/universal }
- { name: Windows, os: ubuntu-latest, platform: windows/amd64 }
- { name: Linux, os: ubuntu-latest, platform: "linux/amd64,linux/arm64" }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install NSIS, for the Windows setup
if: matrix.name == 'Windows'
run: sudo apt-get update && sudo apt-get install -y nsis
- name: Build the Linux daemons the app installs on servers
run: scripts/daemons.sh
- name: Build, and upload to the draft release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
MYGO_UPDATER_PRIVATE_KEY: ${{ secrets.MYGO_UPDATER_PRIVATE_KEY }}
run: go tool mygo build -platform "${{ matrix.platform }}" -upload cmd/enowx
- name: Build
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
env:
GH_TOKEN: ${{ github.token }}
MYGO_UPDATER_PRIVATE_KEY: ${{ secrets.MYGO_UPDATER_PRIVATE_KEY }}
run: go tool mygo build -platform "${{ matrix.platform }}" cmd/enowx
- uses: actions/upload-artifact@v4
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
with:
name: ${{ matrix.name }}
if-no-files-found: error
path: |
build/*/*.dmg
build/*/*Setup*.exe
build/*/*.deb
build/*/*.tar.gz
build/*/*.delta
build/*/update-*.json
build/*/install.sh
# What the website (enowx.ai) shows of the release: its files and their
# sizes as GitHub's API answers, kept as one of its files so the site
# reads it from the release's downloads, which GitHub's API limit spares.
site-manifest:
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && needs.build.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Upload release.json
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api "repos/$GITHUB_REPOSITORY/releases" --paginate --jq ".[] | select(.tag_name == \"$GITHUB_REF_NAME\")" > draft.json
jq --arg repo "$GITHUB_REPOSITORY" --arg tag "$GITHUB_REF_NAME" '{
tag_name: $tag,
html_url: "https://github.com/\($repo)/releases/tag/\($tag)",
published_at: (now | todate),
assets: [.assets[] | select(.name != "release.json") | {name, size,
browser_download_url: "https://github.com/\($repo)/releases/download/\($tag)/\(.name | @uri)"}]
}' draft.json > release.json
gh release upload "$GITHUB_REF_NAME" release.json --clobber --repo "$GITHUB_REPOSITORY"
# Says so on Discord once the release is out. It can't fail the release, and
# scripts/release-discord.py looks for its own post first, so a rerun is safe.
announce:
if: github.event_name == 'release' && !github.event.release.draft && !github.event.release.prerelease
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Post the changelog to Discord
env:
DISCORD_RELEASE_BOT_TOKEN: ${{ secrets.DISCORD_RELEASE_BOT_TOKEN }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_URL: ${{ github.event.release.html_url }}
run: python3 scripts/release-discord.py