Repository navigation
71 lines (62 loc) · 2.85 KB
/
Copy pathsnap.yml
File metadata and controls
71 lines (62 loc) · 2.85 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
# Builds the Linux Snap and (optionally) publishes it to the Snap Store.
# - On a v* tag: builds the .snap, attaches it to the GitHub Release, and — if the
# SNAPCRAFT_STORE_CREDENTIALS secret is set — uploads it to the stable channel.
# - Manual run (workflow_dispatch): just builds + uploads the .snap as an artifact.
#
# To enable auto-publish: create a token with `snapcraft export-login --snaps=downloader \
# --acls package_access,package_push,package_update,package_release -` and add it as the
# repo secret SNAPCRAFT_STORE_CREDENTIALS. Otherwise download the artifact and run
# `snapcraft upload --release=stable` yourself.
name: Snap
on:
push:
tags: [ "v*" ]
workflow_dispatch:
permissions:
contents: write # let action-gh-release attach the .snap to the release
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v5
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Publish self-contained linux-x64
run: |
VER=$(grep -oPm1 '(?<=<VersionPrefix>)[^<]+' src/Downloader.Desktop/Downloader.Desktop.csproj)
[[ "$GITHUB_REF" == refs/tags/v* ]] && VER="${GITHUB_REF_NAME#v}"
echo "$VER" > snap/local/VERSION
dotnet publish src/Downloader.Desktop/Downloader.Desktop.csproj \
-c Release -r linux-x64 --self-contained true \
-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true \
-p:EnableCompressionInSingleFile=true -p:DebugType=None -p:DebugSymbols=false \
-p:VersionPrefix="$VER" -o publish/linux-x64
mv -f publish/linux-x64/Downloader.Desktop publish/linux-x64/Downloader || true
chmod +x publish/linux-x64/Downloader || true
- name: Build snap
id: snapcraft
uses: snapcore/action-build@v1
- name: Upload snap artifact
uses: actions/upload-artifact@v6
with:
name: downloader-snap
path: "*.snap"
- name: Attach snap to the GitHub Release
if: startsWith(github.ref, 'refs/tags/')
continue-on-error: true # store publish below is what matters; don't fail the run on attach
uses: softprops/action-gh-release@v3
with:
files: "*.snap"
# No generate_release_notes here: it races release.yml's create ("tag_name already_exists").
# The release.yml `notes` job fills notes once; scripts/release.sh sets curated notes.
- name: Publish to the Snap Store
if: ${{ always() && startsWith(github.ref, 'refs/tags/') && env.SNAPCRAFT_STORE_CREDENTIALS != '' }}
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.snapcraft.outputs.snap }}
release: stable