Core - Release Docker #12
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: Core - Release Docker | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Release tag to download binaries from, must be an existing release" | |
required: true | |
type: string | |
stable: | |
description: "Is this a stable release?" | |
required: true | |
type: boolean | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }}_core | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
core-release-docker: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./core | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v3 | |
- name: set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: set up docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: log in to the container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: string_tag | |
uses: ASzc/change-string-case-action@v5 | |
with: | |
string: ${{ env.REGISTRY}}/${{ env.IMAGE_NAME }} | |
- id: release_asset | |
name: Download release assets | |
uses: dsaltares/fetch-gh-release-asset@master | |
with: | |
regex: true | |
file: "lodestone_core_.*" | |
target: core/release/ | |
version: "tags/${{ inputs.version || github.ref_name }}" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# https://stackoverflow.com/questions/73402042/github-action-expressions-split-string | |
- name: set version string | |
env: | |
VERSION: ${{ steps.release_asset.outputs.version }} | |
id: substring | |
run: echo "version=${VERSION:1}" >> $GITHUB_OUTPUT | |
- name: set docker version label | |
env: | |
LABEL: ${{ (inputs.stable || !github.event.release.prerelease) && 'latest-stable' || 'latest-beta' }} | |
id: release_type | |
run: echo "label=${LABEL}" >> $GITHUB_OUTPUT | |
- name: build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./core | |
platforms: linux/amd64,linux/arm64 | |
file: ./core/githubactions.Dockerfile | |
build-args: | | |
lodestone_version=${{ steps.release_asset.outputs.version }} | |
push: true | |
tags: | | |
${{ steps.string_tag.outputs.lowercase }}:latest | |
${{ steps.string_tag.outputs.lowercase }}:${{ steps.release_type.outputs.label }} | |
${{ steps.string_tag.outputs.lowercase }}:${{ steps.substring.outputs.version }} |