Remove incorrect groups from dependabot config [skip release] (#755) #606
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: | |
- main | |
- release/* | |
concurrency: release-${{github.ref}} | |
permissions: | |
contents: read | |
jobs: | |
ci: | |
name: CI | |
uses: ./.github/workflows/ci.yml | |
cd: | |
name: CD | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
if: (!contains(github.event.head_commit.message, '[skip release]')) | |
permissions: | |
contents: write | |
packages: write | |
needs: | |
- ci | |
env: | |
PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le | |
PACKAGE: ghcr.io/${{github.repository_owner}}/base-ubuntu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3.0.0 | |
with: | |
platforms: ${{env.PLATFORMS}} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.1.0 | |
id: buildx | |
- name: Set up cache | |
uses: actions/cache@v4.0.1 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{runner.os}}-buildx-${{github.sha}} | |
restore-keys: ${{runner.os}}-buildx- | |
- name: Determine info | |
id: info | |
shell: bash | |
run: | | |
VERSION=$(grep -E '^FROM ubuntu:[a-z]+-[0-9]+$' Dockerfile) | |
VERSION=${VERSION##*:} | |
STREAM=${VERSION%-*} | |
if [[ -z "$STREAM" ]]; then | |
STREAM=$VERSION | |
fi | |
URL=https://api.github.com/repos/${{github.repository}} | |
AUTHORIZATION_HEADER="Authorization: token $GITHUB_TOKEN" | |
FILTER=".[].tag_name|select(startswith(\"$VERSION\"))" | |
FILTER="$FILTER|sub(\"^$VERSION$DELIMITER\";\"\")|tonumber" | |
FILTER="[$FILTER]|max" | |
BUILD_NUMBER=$( | |
curl -H "$AUTHORIZATION_HEADER" -sfSL "$URL/releases" | | |
jq -r "$FILTER" | |
) | |
if [[ -z "$BUILD_NUMBER" || "$BUILD_NUMBER" == 'null' ]]; then | |
BUILD_NUMBER='0' | |
else | |
RELEASE_SHA=$( | |
curl -H "$AUTHORIZATION_HEADER" \ | |
-sfSL "$URL/git/refs/tags/$VERSION$DELIMITER$BUILD_NUMBER" | | |
jq -r '.object.sha' | |
) | |
if [[ "$RELEASE_SHA" == "$GITHUB_SHA" ]]; then | |
echo 'Uh oh...😧 something went wrong' | |
echo 'The current release is already at the current commit 😕' | |
exit 1 | |
fi | |
BUILD_NUMBER=$((BUILD_NUMBER + 1)) | |
fi | |
RELEASE_VERSION="$VERSION$DELIMITER$BUILD_NUMBER" | |
RELEASE_BRANCH=${GITHUB_REF#refs/heads/} | |
DOCKER_TAGS="$PACKAGE:$RELEASE_VERSION" | |
DOCKER_TAGS="$DOCKER_TAGS,$PACKAGE:$STREAM" | |
if [[ "$RELEASE_BRANCH" == 'main' ]]; then | |
DOCKER_TAGS="$DOCKER_TAGS,$PACKAGE:latest" | |
fi | |
RELEASE_COMMIT="$GITHUB_SHA" | |
DATETIME=$(date --utc +%FT%T.%3NZ) | |
echo 'Create Release: true' | |
echo "Datetime: $DATETIME" | |
echo "Release Version: $RELEASE_VERSION" | |
echo "Release Branch: $RELEASE_BRANCH" | |
echo "Release Commit: $RELEASE_COMMIT" | |
echo "Docker Tags: $DOCKER_TAGS" | |
echo 'create-release=true' >> $GITHUB_OUTPUT | |
echo "datetime=$DATETIME" >> $GITHUB_OUTPUT | |
echo "release-version=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
echo "release-branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT | |
echo "release-commit=$RELEASE_COMMIT" >> $GITHUB_OUTPUT | |
echo "docker-tags=$DOCKER_TAGS" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{github.token}} | |
DELIMITER: '.' | |
- name: Login to registry | |
if: steps.info.outputs.create-release | |
uses: docker/login-action@v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{github.token}} | |
- name: Build & push image | |
if: steps.info.outputs.create-release | |
uses: docker/build-push-action@v5.2.0 | |
with: | |
context: . | |
builder: ${{steps.buildx.outputs.name}} | |
platforms: ${{env.PLATFORMS}} | |
build-args: | | |
BUILD_DATETIME=${{steps.info.outputs.datetime}} | |
BUILD_VERSION=${{steps.info.outputs.release-version}} | |
BUILD_REVISION=${{steps.info.outputs.release-commit}} | |
tags: ${{steps.info.outputs.docker-tags}} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
push: true | |
- name: Create release | |
if: steps.info.outputs.create-release | |
run: | | |
git tag "$TAG" "$COMMIT" | |
git push origin tag "$TAG" | |
gh release create "$TAG" \ | |
--target "$BRANCH" \ | |
--title "$TAG" \ | |
--verify-tag \ | |
--generate-notes | |
env: | |
TAG: ${{steps.info.outputs.release-version}} | |
BRANCH: ${{steps.info.outputs.release-branch}} | |
COMMIT: ${{steps.info.outputs.release-commit}} | |
GITHUB_TOKEN: ${{github.token}} | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |