release #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
fetch-depth: '0' | |
- name: Set env variables | |
run: | | |
echo "GITHUB_DATE=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV | |
echo "GITHUB_SHA=${{ github.sha }}" >> $GITHUB_ENV | |
- name: Get latest Webapp release version | |
run: | | |
WEBAPP_RELEASE=$(curl -sX GET "https://api.github.com/repos/netbootxyz/webapp/releases/latest" | jq -r '. | .tag_name') | |
echo "WEBAPP_RELEASE=${WEBAPP_RELEASE}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Login to the Docker Container Registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to the GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GHCR_USER }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Determine version numbers | |
id: version_check | |
continue-on-error: true | |
run: | | |
IMAGE=netbootxyz/netbootxyz | |
TOKEN=$(curl -sX GET \ | |
"https://ghcr.io/token?scope=repository%3Anetbootxyz%2Fnetbootxyz%3Apull" \ | |
| jq -r '.token') | |
TAG=$(curl -s --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ | |
--header "Authorization: Bearer ${TOKEN}" \ | |
"https://ghcr.io/v2/${IMAGE}/tags/list?n=1000" \ | |
| jq -r '.tags[-1]') | |
echo LATEST_TAG: $TAG | |
MULTIDIGEST=$(curl -s \ | |
--header "Accept: application/vnd.oci.image.index.v1+json" \ | |
--header "Authorization: Bearer ${TOKEN}" \ | |
"https://ghcr.io/v2/${IMAGE}/manifests/${TAG}" \ | |
| jq -r 'first(.manifests[].digest)') | |
DIGEST=$(curl -s \ | |
--header "Accept: application/vnd.oci.image.manifest.v1+json" \ | |
--header "Authorization: Bearer ${TOKEN}" \ | |
"https://ghcr.io/v2/${IMAGE}/manifests/${MULTIDIGEST}" \ | |
| jq -r '.config.digest') | |
IMAGE_INFO=$(curl -sL \ | |
--header "Authorization: Bearer ${TOKEN}" \ | |
"https://ghcr.io/v2/${IMAGE}/blobs/${DIGEST}" \ | |
| jq -r '.config') | |
IMAGE_RELEASE=$(echo ${IMAGE_INFO} | jq -r '.Labels.build_version' | awk '{print $3}') | |
IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $1}') | |
NB_RELEASE_NUMBER=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $2}') | |
TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE}) | |
if [ -z "${MULTIDIGEST}" ] || [ "${MULTIDIGEST}" == "null" ]; then | |
echo "**** No existing container build found, assuming first build ****" | |
VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1 | |
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV | |
elif [ "${WEBAPP_RELEASE}" == "${IMAGE_VERSION}" ]; then | |
echo "**** Version ${WEBAPP_RELEASE} unchanged, checking if there is anything to build..." | |
if [ "${TAG_SHA}" == "${GITHUB_SHA}" ]; then | |
echo "**** Nothing to do, exiting build... **** " | |
exit 1 | |
else | |
echo "**** Changes found... incrementing build number version... ****" | |
NB_RELEASE_NUMBER=$((NB_RELEASE_NUMBER + 1)) | |
VERSION_TAG=${IMAGE_VERSION}-nbxyz${NB_RELEASE_NUMBER} | |
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV | |
fi | |
else | |
echo "**** New version ${WEBAPP_RELEASE} found; old version was ${IMAGE_VERSION}. Generating new webapp release... ****" | |
VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1 | |
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV | |
fi | |
- name: Docker meta | |
if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: netbootxyz/netbootxyz | |
labels: | | |
maintainer=antonym | |
org.opencontainers.image.created=${{ env.GITHUB_DATE }} | |
org.opencontainers.image.authors=netboot.xyz | |
org.opencontainers.image.url=https://github.com/netbootxyz/docker-netbootxyz/packages | |
org.opencontainers.image.documentation=https://netboot.xyz | |
org.opencontainers.image.source=https://github.com/netbootxyz/docker-netbootxyz | |
org.opencontainers.image.version=${{ env.VERSION_TAG }} | |
org.opencontainers.image.revision=${{ env.GITHUB_SHA }} | |
org.opencontainers.image.vendor=netboot.xyz | |
org.opencontainers.image.licenses=Apache-2.0 | |
org.opencontainers.image.ref.name=${{ env.GITHUB_SHA }} | |
org.opencontainers.image.title=netbootxyz | |
org.opencontainers.image.description=netboot.xyz official docker container - Your favorite operating systems in one place. A network-based bootable operating system installer based on iPXE. | |
- name: Build and push image | |
if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
build-args: | | |
WEBAPP_VERSION=${{ env.WEBAPP_RELEASE }} | |
VERSION=${{ env.VERSION_TAG }} | |
BUILD_DATE=${{ env.GITHUB_DATE }} | |
tags: | | |
netbootxyz/netbootxyz:latest | |
netbootxyz/netbootxyz:${{ github.sha }} | |
netbootxyz/netbootxyz:${{ env.VERSION_TAG }} | |
ghcr.io/netbootxyz/netbootxyz:latest | |
ghcr.io/netbootxyz/netbootxyz:${{ github.sha }} | |
ghcr.io/netbootxyz/netbootxyz:${{ env.VERSION_TAG }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Bump version and push tag | |
if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' | |
id: tag_version | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CUSTOM_TAG: ${{ env.VERSION_TAG }} | |
WITH_V: true | |
RELEASE_BRANCHES: master |