Skip to content

Commit b1cb8ea

Browse files
authored
ci(release): add dispatch GHA for snapcraft classic release (#1256)
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
1 parent 2d0431d commit b1cb8ea

File tree

2 files changed

+69
-13
lines changed

2 files changed

+69
-13
lines changed

.github/workflows/release-snap.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright The ORAS Authors.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
name: release-snap
15+
16+
on:
17+
workflow_dispatch:
18+
inputs:
19+
version:
20+
description: 'release version, like v1.2.0-beta.1'
21+
required: true
22+
isStable:
23+
type: boolean
24+
description: 'check for stable release'
25+
default: false
26+
27+
jobs:
28+
release-snap:
29+
strategy:
30+
matrix:
31+
arch:
32+
- 'amd64'
33+
- 'arm64'
34+
- 's390x'
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: read
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v3
41+
- name: extract version
42+
id: version
43+
run: |
44+
if [[ "${{ github.event.inputs.isStable }}" == "true" ]]; then
45+
echo "release=stable" >> $GITHUB_OUTPUT
46+
else
47+
echo "release=candidate" >> $GITHUB_OUTPUT
48+
fi
49+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
50+
- name: make snapcraft
51+
run: |
52+
sed -i 's/{VERSION}/${{ steps.version.outputs.version }}/g' snapcraft.yaml
53+
sed -i 's/{ARCH}/${{ matrix.arch }}/g' snapcraft.yaml
54+
cat snapcraft.yaml
55+
- uses: snapcore/action-build@v1
56+
id: build
57+
- uses: snapcore/action-publish@v1
58+
name: publish
59+
env:
60+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
61+
with:
62+
snap: ${{ steps.build.outputs.snap }}
63+
release: ${{ steps.version.outputs.release }}
64+

snapcraft.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@
1212
# limitations under the License.
1313

1414
name: oras
15-
version: 'v1.0.0'
15+
version: '{VERSION}'
1616
summary: Package for the ORAS CLI tool
1717
description: |
1818
A snap package for the ORAS CLI tool, which is used for managing OCI artifacts.
1919
base: core22
20-
confinement: strict
20+
confinement: classic
2121
grade: stable
2222

2323
architectures:
2424
- build-on: amd64
25-
build-for: amd64
26-
- build-on: amd64
27-
build-for: arm64
28-
- build-on: amd64
29-
build-for: s390x
25+
build-for: {ARCH}
3026

3127
parts:
3228
oras:
@@ -35,12 +31,8 @@ parts:
3531
source-type: git
3632
source-tag: $SNAPCRAFT_PROJECT_VERSION
3733
build-environment:
38-
- on amd64 to amd64:
39-
- TARGET_ARCH: "amd64"
40-
- on amd64 to arm64:
41-
- TARGET_ARCH: "arm64"
42-
- on amd64 to s390x:
43-
- TARGET_ARCH: "s390x"
34+
- on amd64 to {ARCH}:
35+
- TARGET_ARCH: "{ARCH}"
4436
build-snaps:
4537
- go/1.22/stable
4638
build-packages:

0 commit comments

Comments
 (0)