Skip to content

Commit 7978212

Browse files
committed
use new gl-oci and fix artifact naming
1 parent 5e663fe commit 7978212

1 file changed

Lines changed: 37 additions & 54 deletions

File tree

.github/workflows/upload_oci.yml

Lines changed: 37 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ jobs:
2626
fail-fast: false
2727
matrix: ${{ fromJson(needs.generate_matrix_publish.outputs.matrix) }}
2828
steps:
29-
- uses: oras-project/setup-oras@v1
30-
- run: oras version
3129
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v4.1.1
3230
with:
3331
submodules: 'true'
32+
- uses: oras-project/setup-oras@v1
33+
- run: oras version
34+
- name: Install python-gardenlinux-lib
35+
uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@a7545af15d3a1fa96675b24807eace643483da96 # pin@0.8.0
36+
- name: Install cosign
37+
uses: sigstore/cosign-installer@v3.9.1
38+
with:
39+
cosign-release: 'v2.4.1'
3440
# bin/garden-version reads and writes from and to ./VERSION which is read by ./build --resolve-cname
3541
- name: set VERSION=${{ inputs.version }}
3642
run: |
@@ -39,57 +45,35 @@ jobs:
3945
ver=$(cat VERSION)
4046
git update-index --assume-unchanged VERSION
4147
git update-index --assume-unchanged gardenlinux # do not track gardenlinux submodule changes
42-
cname="$(./build --resolve-cname ${{ matrix.flavor }}-${{ matrix.arch }})"
43-
echo "cname=$cname" | tee -a "$GITHUB_ENV"
48+
echo "CNAME=$(gl-features-parse --cname ${{ matrix.flavor }}-${{ matrix.arch }} cname)" | tee -a "$GITHUB_ENV"
4449
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # pin@v4.1.8
4550
with:
46-
name: build-${{ env.cname }}
47-
- name: Untar workflow artifact
48-
run: |
49-
mkdir ${{ env.cname }}
50-
tar -C ${{ env.cname }} -xzv < "${{ env.cname }}.tar.gz"
51-
- name: Set up Python 3.12
52-
uses: actions/setup-python@v5
53-
with:
54-
python-version: "3.12"
55-
- name: Install glcli util
56-
run: |
57-
git clone --depth 1 --branch 0.6.4 https://github.com/gardenlinux/python-gardenlinux-cli.git
58-
mv python-gardenlinux-cli /opt/glcli
59-
pip install -r /opt/glcli/requirements.txt
60-
- name: push using the glcli util
51+
name: build-${{ matrix.flavor }}-${{ matrix.arch }}
52+
- name: Push using the glcli util
53+
env:
54+
GL_CLI_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
GL_CLI_REGISTRY_USERNAME: ${{ github.repository_owner }}
6156
run: |
62-
mkdir -p manifests
63-
max_retries=3
64-
retry_count=0
65-
exit_code=0
66-
until [ $retry_count -ge $max_retries ]; do
67-
if output=$(GLOCI_REGISTRY_TOKEN=${{ secrets.GITHUB_TOKEN }} GLOCI_REGISTRY_USERNAME=${{ github.repository_owner }} python /opt/glcli/src/glcli.py push-manifest --dir ${{ env.cname }} --container ghcr.io/${{ github.repository }} --arch ${{ matrix.arch }} --version ${{ inputs.version }} --cname ${{ env.cname }} --cosign_file digest --manifest_file manifests/oci_manifest_entry_${{ env.cname }}.json 2>&1); then
68-
echo "$output"
69-
exit 0
70-
elif echo "$output" | grep -q "Bad Gateway"; then
71-
retry_count=$((retry_count+1))
72-
exit_code=1
73-
echo "Bad Gateway detected, retry $retry_count/$max_retries"
74-
sleep 10
75-
else
76-
echo "Fatal error: $output"
77-
exit $exit_code
78-
fi
79-
done
80-
if [ $exit_code -ne 0 ]; then
81-
echo "Failed after $max_retries retries"
82-
exit 1
83-
fi
57+
mkdir "$CNAME"
58+
59+
tar -C "$CNAME" -xzf "$CNAME.tar.gz"
60+
61+
gl-oci push-manifest \
62+
--dir ${CNAME} \
63+
--container "ghcr.io/${{ github.repository }}" \
64+
--arch ${{ matrix.arch }} \
65+
--version ${{ inputs.version }} \
66+
--cname ${CNAME} \
67+
--cosign_file digest \
68+
--manifest_file "manifests/oci_manifest_entry_${CNAME}.json"
8469
- name: Add additional semver tag
8570
run: |
8671
echo ${{ secrets.GITHUB_TOKEN }} | oras login -u ${{ github.repository_owner }} --password-stdin ghcr.io
87-
CNAME="${{ env.cname }}"
88-
oras tag ghcr.io/${{ github.repository }}:${{ inputs.version }}-${{ env.cname }}-${{ matrix.arch }} ${{ inputs.version }}.0-${CNAME//_/-}-${{ matrix.arch }}
72+
oras tag ghcr.io/${{ github.repository }}:${{ inputs.version }}-${CNAME}-${{ matrix.arch }} ${{ inputs.version }}.0-${CNAME//_/-}-${{ matrix.arch }}
8973
- name: Upload oci manifest artifact
9074
uses: actions/upload-artifact@v4
9175
with:
92-
name: oci_manifest_entry_${{ env.cname }}.json
76+
name: oci_manifest_entry_${{ env.CNAME }}.json
9377
path: manifests/
9478
- name: Output digest to be signed
9579
run: |
@@ -107,24 +91,23 @@ jobs:
10791
packages: write
10892
actions: write
10993
steps:
110-
- name: Set up Python 3.12
111-
uses: actions/setup-python@v5
112-
with:
113-
python-version: "3.12"
114-
- name: Install glcli util
115-
run: |
116-
git clone --depth 1 --branch 0.6.2 https://github.com/gardenlinux/python-gardenlinux-cli.git
117-
mv python-gardenlinux-cli /opt/glcli
118-
pip install -r /opt/glcli/requirements.txt
94+
- name: Install python-gardenlinux-lib
95+
uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@a7545af15d3a1fa96675b24807eace643483da96 # pin@0.8.0
11996
- name: Download OCI manifest artifacts
12097
uses: actions/download-artifact@v4
12198
with:
12299
path: manifests
123100
pattern: oci_manifest_entry_*
124101
merge-multiple: true
125102
- name: Update index using glcli tool
103+
env:
104+
GL_CLI_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
GL_CLI_REGISTRY_USERNAME: ${{ github.repository_owner }}
126106
run: |
127-
GLOCI_REGISTRY_TOKEN=${{ secrets.GITHUB_TOKEN }} GLOCI_REGISTRY_USERNAME=${{ github.repository_owner }} python /opt/glcli/src/glcli.py update-index --container ghcr.io/${{ github.repository }} --version ${{ inputs.version }} --manifest_folder manifests
107+
gl-oci update-index \
108+
--container "ghcr.io/${{ github.repository }}" \
109+
--version ${{ inputs.version }} \
110+
--manifest_folder manifests
128111
- name: Delete temporary OCI manifest entry files
129112
uses: actions/github-script@v7
130113
with:

0 commit comments

Comments
 (0)