Repository navigation
86 lines (80 loc) · 2.86 KB
/
Copy pathrelease-snap.yml
File metadata and controls
86 lines (80 loc) · 2.86 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
# Copyright The ORAS Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: release-snap
on:
workflow_dispatch:
inputs:
version:
description: 'release version, like v1.2.0-beta.1'
required: true
isStable:
type: boolean
description: 'check for stable release'
default: false
jobs:
release-snap:
strategy:
matrix:
arch:
- 'amd64'
- 'arm64'
- 's390x'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: extract version
id: version
run: |
# The store token can only release to stable. candidate, beta and
# edge are closed and follow stable, so pre-releases aren't published.
echo "release=stable" >> $GITHUB_OUTPUT
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
- name: make snapcraft
run: |
sed -i 's/{VERSION}/${{ steps.version.outputs.version }}/g' snapcraft.yaml
sed -i 's/{ARCH}/${{ matrix.arch }}/g' snapcraft.yaml
cat snapcraft.yaml
- name: build
id: build
env:
SNAPCRAFT_BUILD_ENVIRONMENT: lxd
SNAPCRAFT_IMAGE_INFO: '{"build_url":"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
run: |
sudo chown root:root /
sudo groupadd --force --system lxd
sudo usermod --append --groups lxd "$(id -un)"
if [ -x /snap/bin/lxd ]; then
sudo snap refresh lxd
else
sudo snap install lxd
fi
sudo lxd init --auto
sudo iptables -P FORWARD ACCEPT
if [ -x /snap/bin/snapcraft ]; then
sudo snap refresh --classic snapcraft
else
sudo snap install --classic snapcraft
fi
sudo -u "$(id -un)" -E /snap/bin/snapcraft
echo "snap=$(ls ./*.snap)" >> "$GITHUB_OUTPUT"
- name: publish
if: ${{ inputs.isStable }}
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
SNAP_FILE: ${{ steps.build.outputs.snap }}
SNAP_RELEASE: ${{ steps.version.outputs.release }}
run: |
/snap/bin/snapcraft upload "$SNAP_FILE" --release "$SNAP_RELEASE"