-
Notifications
You must be signed in to change notification settings - Fork 3
114 lines (100 loc) · 4.18 KB
/
Copy pathsnap-publish.yml
File metadata and controls
114 lines (100 loc) · 4.18 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
# Builds and publishes the etherpad-desktop snap on tagged releases.
# Mirrors etherpad-lite's pattern: build → edge → manual-gate → stable.
#
# Note: `on.push.tags` uses GitHub's filter-pattern globs, NOT regex — so the
# pattern must be expressed as two glob entries, not a single `v?...` regex.
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
#
# One-time maintainer setup:
# 1. snapcraft register etherpad-desktop (claim the name)
# 2. Generate a store credential:
# snapcraft export-login --snaps etherpad-desktop \
# --channels edge,stable \
# --acls package_access,package_push,package_release -
# Save the output as repo secret SNAPCRAFT_STORE_CREDENTIALS.
# 3. Create a GitHub Environment 'snap-store-stable' with required
# reviewers so stable promotion is gated behind manual approval.
#
# Ref: https://documentation.ubuntu.com/snapcraft/latest/how-to/publishing/
name: Snap
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
outputs:
snap-file: ${{ steps.find.outputs.path }}
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install snapcraft
run: sudo snap install snapcraft --classic
# snapcraft requires LXD or multipass for builds; use destructive
# mode in CI which is the recommended approach for ubuntu-latest.
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build app
run: pnpm build
- name: Build snap via electron-builder
env:
USE_SYSTEM_FPM: 'true'
# electron-builder's snap target invokes snapcraft under the hood; in
# CI we want destructive-mode (no LXD container).
SNAPCRAFT_BUILD_ENVIRONMENT: 'host'
# --publish never: electron-builder otherwise tries to push to the
# Snap Store during build when it sees a git tag, but
# SNAPCRAFT_STORE_CREDENTIALS is only available in the publish-*
# jobs below. Disable implicit publish; the dedicated job uses
# snapcore/action-publish with the credentials properly scoped.
run: pnpm exec electron-builder --linux snap --config build/electron-builder.yml --publish never
- name: Locate snap file
id: find
# Output the BASENAME, not release/<name>.snap. actions/upload-artifact
# flattens release/*.snap into the artifact root, so when publish-edge
# downloads it the file lands at the workspace root — `release/` doesn't
# exist there. Using just the basename keeps the same path valid in
# both the build job (after `cd release` is implicit) and the publish
# job (after artifact download).
run: |
file=$(ls release/*.snap | head -n1)
echo "path=$(basename "$file")" >> "$GITHUB_OUTPUT"
- name: Upload snap artifact
uses: actions/upload-artifact@v7
with:
name: etherpad-desktop-snap
path: release/*.snap
if-no-files-found: error
retention-days: 7
publish:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/download-artifact@v8
with:
name: etherpad-desktop-snap
# Release to BOTH edge and stable in one upload. Splitting them
# into two jobs (each calling snapcore/action-publish) means the
# second one re-uploads the identical binary, which the Snap
# Store rejects with `binary_sha3_384: Error checking upload
# uniqueness`. snapcraft accepts a comma-separated channel list,
# so a single upload can release to multiple channels.
- name: Publish to edge + stable
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ needs.build.outputs.snap-file }}
release: edge,stable