Files
godot-ci/.github/workflows/release.yml

102 lines
4.4 KiB
YAML

name: Release
on:
release:
types: [released]
env:
IMAGE_NAME: godot-ci
jobs:
version:
name: Get Version
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.calculate.outputs.version }}
release_name: ${{ steps.calculate.outputs.release_name }}
dotnet_version: ${{ steps.calculate.outputs.dotnet_version }}
steps:
- id: calculate
run: |
REF_NAME=${{ github.ref_name }}
echo "version=${REF_NAME%-*}" >> $GITHUB_OUTPUT
echo "release_name=${REF_NAME#*-}" >> $GITHUB_OUTPUT
MAJOR_VERSION=$(echo ${REF_NAME%-*} | cut -c -1)
MINOR_VERSION=$(echo ${REF_NAME%-*} | cut -c -3)
if [ "$MAJOR_VERSION" = "3" ]
then
echo "dotnet_version=mono:latest" >> $GITHUB_OUTPUT
elif [ "$MINOR_VERSION" = "4.0" ] || [ "$MINOR_VERSION" = "4.1" ] || [ "$MINOR_VERSION" = "4.2" ] || [ "$MINOR_VERSION" = "4.3" ]
then
echo "dotnet_version=mcr.microsoft.com/dotnet/sdk:6.0-jammy" >> $GITHUB_OUTPUT
else
echo "dotnet_version=mcr.microsoft.com/dotnet/sdk:8.0-jammy" >> $GITHUB_OUTPUT
fi
build:
name: Build Image
runs-on: ubuntu-24.04
needs: [version]
steps:
- uses: actions/checkout@v3
- run: echo IMAGE_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1.14.1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2.9.0
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:${{ needs.version.outputs.version }}
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.version.outputs.version }}
build-args: |
GODOT_VERSION=${{ needs.version.outputs.version }}
RELEASE_NAME=${{ needs.version.outputs.release_name }}
GODOT_TEST_ARGS=${{ startsWith( needs.version.outputs.version, '3.' ) && '' || '--headless --quit' }}
GODOT_PLATFORM=${{ startsWith( needs.version.outputs.version, '3.' ) && 'linux_headless.64' || 'linux.x86_64' }}
build-mono:
name: Build Mono Image
runs-on: ubuntu-24.04
needs: [version]
steps:
- uses: actions/checkout@v3
- run: echo IMAGE_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1.14.1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2.9.0
with:
context: .
file: mono.Dockerfile
push: true
tags: |
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:mono-${{ needs.version.outputs.version }}
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:mono-latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:mono-latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:mono-${{ needs.version.outputs.version }}
build-args: |
IMAGE=${{ needs.version.outputs.dotnet_version }}
GODOT_VERSION=${{ needs.version.outputs.version }}
RELEASE_NAME=${{ needs.version.outputs.release_name }}
ZIP_GODOT_PLATFORM=${{ startsWith( needs.version.outputs.version, '3.' ) && 'linux_headless_64' || 'linux_x86_64' }}
FILENAME_GODOT_PLATFORM=${{ startsWith( needs.version.outputs.version, '3.' ) && 'linux_headless.64' || 'linux.x86_64' }}