Skip to content

Commit

Permalink
Fix uploading snap to multiple channels
Browse files Browse the repository at this point in the history
Currently only the latest args `--release` is used by snapcraft for upload.

Rework the script to output the channel values instead of the `--release=$channel` args.
Then iterate over the channels to upload the snap to each of them.
  • Loading branch information
FirelightFlagboy committed Jul 26, 2024
1 parent 8bad1b5 commit 6623919
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
- name: Get releases for snapcraft
run: |
set -o pipefail
python misc/snapcraft_releases.py ${{ inputs.nightly && '--nightly' || '' }} ${{ steps.version.outputs.full }} | tee ${{ runner.temp }}/snap-releases-args
python misc/snapcraft_releases.py ${{ inputs.nightly && '--nightly' || '' }} ${{ steps.version.outputs.full }} | tee ${{ runner.temp }}/snap-release-channels
timeout-minutes: 1

- name: Check that snapcraft credential is not empty
Expand All @@ -126,10 +126,15 @@ jobs:
timeout-minutes: 2

- name: Upload Snap
run: snapcraft upload $(cat ${{ runner.temp }}/snap-releases-args) snap/Parsec_${{ steps.version.outputs.full }}_linux_*.snap
run: |
set -x
for channel in $(cat ${{ runner.temp }}/snap-release-channels); do
snapcraft upload --releases=$channel snap/Parsec_${{ steps.version.outputs.full }}_linux_*.snap
done
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_CREDENTIALS }}
timeout-minutes: 5
# Each upload take ~2min, we could have up to 4 channel to upload so: `2 * 4 = 8min` (plus a little spare)
timeout-minutes: 10

- name: Publish wheel on PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # pin v1.9.0
Expand Down
32 changes: 14 additions & 18 deletions misc/snapcraft_releases.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS
"""
For a given Parsec version, this script outputs the `--release=<channel>` options intended for snapcraft.
For a given Parsec version, this script outputs the `<channel>` value intended to be used in the `--releases=<channel>` option for `snapcraft upload`.
- A channel is formed with <track>/<risk-level>/<branch>
- Parsec currently has 4 tracks: latest, v2, v3, nigthly
Expand All @@ -9,17 +9,17 @@
E.g.
$ python misc/snapcraft_releases.py 2.0.0
--release=v2/stable
v2/stable
$ python misc/snapcraft_releases.py 3.0.0-b.0
--release=v3/beta
--release=latest/beta
v3/beta
latest/beta
$ python misc/snapcraft_releases.py 3.0.0-b.0 --nightly
--release=v3/edge
--release=latest/edge
--release=nightly/stable
--release=nightly/beta
--release=nightly/edge
--release=nightly/candidate
v3/edge
latest/edge
nightly/stable
nightly/beta
nightly/edge
nightly/candidate
"""

import logging
Expand Down Expand Up @@ -93,7 +93,7 @@ def get_risk_level_for_version(version: Version) -> RiskLevel:
parser = ArgumentParser(
"snapcraft_releases",
description="""
Output as many snapcraft's `--release=<channel>` options based on the given Parsec version.
Output as many snapcraft's `<channel>` values based on the given Parsec version.
""",
epilog="See https://snapcraft.io/docs/channels",
)
Expand All @@ -118,16 +118,12 @@ def get_risk_level_for_version(version: Version) -> RiskLevel:
release_channels: list[str] = []
if args.nightly:
# Update channels "<tracks>/edge"
release_channels.extend(
map(lambda track: f"--release={track}/{RiskLevel.Edge}", tracks_for_version)
)
release_channels.extend(map(lambda track: f"{track}/{RiskLevel.Edge}", tracks_for_version))
# Update channels "nightly/<risk>"
release_channels.extend(
map(lambda risk: f"--release={Track.Nightly}/{risk}", ALL_RISK_LEVEL)
)
release_channels.extend(map(lambda risk: f"{Track.Nightly}/{risk}", ALL_RISK_LEVEL))
else:
risk = get_risk_level_for_version(version)
release_channels.extend(map(lambda track: f"--release={track}/{risk}", tracks_for_version))
release_channels.extend(map(lambda track: f"{track}/{risk}", tracks_for_version))

log.debug(" ".join(release_channels))
print(*release_channels, sep="\n")

0 comments on commit 6623919

Please sign in to comment.