Skip to content

Commit

Permalink
Implement OCI distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
baurmatt committed Dec 6, 2024
1 parent 33e1274 commit 4013511
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: goreleaser
name: release

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
tags:
- '*'
- "*"

jobs:
goreleaser:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -24,3 +28,7 @@ jobs:
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build OCI artifacts
run: ci/release-oci-artifacts.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
# Go workspace file
go.work
fleeting-plugin-openstack

# goreleaser build directory
dist/
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: 2
builds:
- # First Build
- # First Build
env:
- CGO_ENABLED=0
main: ./cmd/fleeting-plugin-openstack
Expand All @@ -11,8 +12,7 @@ builds:
-X github.com/sardinasystems/fleeting-plugin-openstack.BuildUser=goreleaser@github-actions
-X github.com/sardinasystems/fleeting-plugin-openstack.BuildDate={{time "20060102-15:04:05"}}
# Set the binary output location to bin/ so archive will comply with Sensu Go Asset structure
binary: bin/{{ .ProjectName }}
binary: "{{ .ProjectName }}"
goos:
- linux
goarch:
Expand Down
41 changes: 41 additions & 0 deletions ci/release-oci-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -eo pipefail

# convert 'dist/fleeting-plugin-{name}_{os}_{arch}_{arch_verson}/fleeting-plugin-openstack' to 'dist/{os}/{arch}/plugin'
for path in ./dist/fleeting-plugin-*/*; do
dirname=$(dirname $(echo ${path#dist/}))
IFS='_' read -ra parts <<<"${dirname}"

os=${parts[1]}
arch=${parts[2]%.exe}

if [ "$arch" = "arm" ]; then
arch="armv${parts[3]}"
fi

ext=""
if [ "$os" = "windows" ]; then
ext=".exe"
fi

mkdir -p "dist/${os}/${arch}/"
mv "${path}" "dist/${os}/${arch}/plugin${ext}"
done

find ./dist

go install gitlab.com/gitlab-org/fleeting/fleeting-artifact/cmd/fleeting-artifact@latest

exit

VERSION=${GITHUB_REF_NAME:=0.0.0-bleeding}

# login to registry
fleeting-artifact login -username "${GITHUB_ACTOR}" -password "${GITHUB_TOKEN}" "${REGISTRY}"

# releast artifact
IMAGE_DIGEST="$(fleeting-artifact release "${REGISTRY}/${IMAGE_NAME}:${VERSION#v}")"

# keyless sign
cosign sign "${IMAGE_DIGEST}"

0 comments on commit 4013511

Please sign in to comment.