Create duck image #56
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: Create duck image | |
on: | |
push: | |
tags: ['*'] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag' | |
required: true | |
type: string | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
docker: | |
name: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Determine Version from Input | |
if: ${{ github.event.inputs.tag }} | |
run: | | |
export TAG=${{ github.event.inputs.tag }} | |
echo "TAG=$TAG" >> "$GITHUB_ENV" | |
export VERSION=${TAG/release-} | |
export VERSION=${VERSION//-/.} | |
echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
- name: Determine Version | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
run: | | |
echo "TAG=${{ github.ref }}" >> "$GITHUB_ENV" | |
export VERSION=${GITHUB_REF#refs/tags/release-} | |
export VERSION=${VERSION//-/.} | |
echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
- name: Print Version | |
run: echo "Building $VERSION" | |
- name: Print Tag | |
run: echo "Checkout $TAG" | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{env.VERSION}} | |
type=semver,pattern={{major}}.{{minor}},value=${{env.VERSION}} | |
type=semver,pattern={{major}},value=${{env.VERSION}} | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.TAG }} | |
fetch-depth: 0 | |
- run: | | |
export COUNT=$(git rev-list --count ${{ env.TAG }}) | |
mvn -B verify --projects cli/linux --also-make -DskipTests | |
dpkg-deb -R cli/linux/target/release/duck_${{env.VERSION}}.$COUNT_amd64.deb . | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
env: | |
DOCKER_BUILDKIT: 1 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |