-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (71 loc) · 2.92 KB
/
publish.yaml
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
# Publish the rock image to ghcr
name: Publish
on:
workflow_call:
secrets:
token:
required: true
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Log in to the Container registry
uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Use the rockcraft snap to get skopeo because the snap and the apt package on the ubuntu
# archives are very old. Only rockcraft=latest/edge has a newer skopeo version
# TODO(nsklikas): Either use rockcraft=latest/stable or install skopeo from apt when one
# of them is updated
- name: Install Rockcraft to get skopeo
run: |
sudo snap install --classic --channel latest/edge rockcraft
- name: Install yq
run: |
sudo snap install yq
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: rock
- name: Import and push to github package
run: |
image_name="$(yq '.name' rockcraft.yaml)"
version="$(yq '.version' rockcraft.yaml)"
rock_file=$(ls *.rock | tail -n 1)
sudo rockcraft.skopeo \
--insecure-policy \
copy \
oci-archive:"${rock_file}" \
docker-daemon:"ghcr.io/canonical/${image_name}:${version}"
docker push ghcr.io/canonical/${image_name}:${version}
oci-factory:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Golang setup
uses: actions/setup-go@v5
with:
go-version: ">=1.22.0"
# install oci-factory via golang and set path in environment
- name: Install oci-factory
run: |
sudo apt update && sudo apt install -y git
go install github.com/canonical/oci-factory/tools/cli-client/cmd/oci-factory@latest
go install github.com/mikefarah/yq/v4@v4.44.3
echo "OCI_FACTORY=$(go env GOPATH)/bin/oci-factory" >> $GITHUB_ENV
echo "YQ=$(go env GOPATH)/bin/yq" >> $GITHUB_ENV
- name: Set EOLs and version
# special case for hydra due to the canonical fork
run: |
echo EOL_STABLE=$(date -d "$(date +'%Y-%m-%d') +3 month" "+%Y-%m-%d") >> $GITHUB_ENV
echo IMAGE_VERSION_STABLE=$($YQ '.version | split(".").0' rockcraft.yaml) >> $GITHUB_ENV
echo IMAGE_CANONICAL=$($YQ '.version | split("-").1 // ""' rockcraft.yaml) >> $GITHUB_ENV
- name: Release
run: |
$OCI_FACTORY upload -y --release track=$IMAGE_VERSION_STABLE$IMAGE_CANONICAL-22.04,risks=stable,eol=$EOL_STABLE
env:
GITHUB_TOKEN: ${{ secrets.token }}