84 lines
2.9 KiB
YAML
84 lines
2.9 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
# every value can be overridden by a repository secret; the defaults below
|
|
# keep the workflow usable without extra configuration
|
|
env:
|
|
REGISTRY: ${{ secrets.REGISTRY }}
|
|
REGISTRY_REPO: ${{ secrets.REGISTRY_REPO }}
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build package
|
|
run: |
|
|
chmod +x tools/build-package.sh
|
|
./tools/build-package.sh
|
|
cat version.txt
|
|
|
|
- name: Upload workflow artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: vmmngr-package
|
|
path: dist/
|
|
|
|
- name: Install oras
|
|
run: |
|
|
curl -sSL -o /tmp/oras.tgz \
|
|
https://github.com/oras-project/oras/releases/download/v1.2.0/oras_1.2.0_linux_amd64.tar.gz
|
|
tar -xzf /tmp/oras.tgz -C /tmp oras
|
|
sudo install -m 0755 /tmp/oras /usr/local/bin/oras
|
|
oras version
|
|
|
|
- name: Push to registry
|
|
run: |
|
|
set -eu
|
|
REGISTRY="${REGISTRY:-registry.familie-berner.de}"
|
|
REGISTRY_REPO="${REGISTRY_REPO:-xigmanas/vmmngr}"
|
|
[ -n "${REGISTRY_USER:-}" ] || { echo "secret REGISTRY_USER is missing" >&2; exit 1; }
|
|
[ -n "${REGISTRY_TOKEN:-}" ] || { echo "secret REGISTRY_TOKEN is missing" >&2; exit 1; }
|
|
|
|
VERSION=$(cat version.txt | tr -d '\n')
|
|
PKG=$(ls dist/vmmngr-*.tar.gz | head -1)
|
|
PKG_SUM="${PKG}.sha256"
|
|
MEDIA="application/vnd.xigmanas.vmmngr.layer.v1.tar+gzip"
|
|
|
|
echo "registry : ${REGISTRY}"
|
|
echo "image : ${REGISTRY}/${REGISTRY_REPO}"
|
|
echo "version : ${VERSION}"
|
|
|
|
echo "$REGISTRY_TOKEN" | oras login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
|
|
|
|
for TAG in "$VERSION" latest; do
|
|
echo "pushing ${REGISTRY}/${REGISTRY_REPO}:${TAG}"
|
|
oras push "${REGISTRY}/${REGISTRY_REPO}:${TAG}" \
|
|
--artifact-type application/vnd.xigmanas.extension.v1 \
|
|
"$PKG:$MEDIA" \
|
|
"$PKG_SUM:application/vnd.xigmanas.sha256" \
|
|
--annotation "org.opencontainers.image.version=$VERSION" \
|
|
--annotation "org.opencontainers.image.title=vmmngr"
|
|
done
|
|
|
|
- name: Summary
|
|
run: |
|
|
REGISTRY="${REGISTRY:-registry.familie-berner.de}"
|
|
REGISTRY_REPO="${REGISTRY_REPO:-xigmanas/vmmngr}"
|
|
VERSION=$(cat version.txt | tr -d '\n')
|
|
{
|
|
echo "### vmmngr ${VERSION}"
|
|
echo ""
|
|
echo "Package: \`dist/vmmngr-${VERSION}.tar.gz\`"
|
|
echo ""
|
|
echo "Pull: \`oras pull ${REGISTRY}/${REGISTRY_REPO}:${VERSION}\`"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|