Files
gameyfin/.github/workflows/release.yml
T
2025-07-16 10:17:19 +02:00

138 lines
4.8 KiB
YAML

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (leave empty to use current)'
required: false
update_version:
description: 'Update version and commit version bump?'
required: true
default: true
type: boolean
jobs:
setup:
runs-on: ubuntu-latest
permissions:
contents: write
env:
RELEASE_VERSION: ${{ github.event.inputs.version }}
outputs:
release_version: ${{ steps.get_version.outputs.release_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from build.gradle.kts if not provided
id: get_version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
VERSION=$(grep '^version = ' build.gradle.kts | sed 's/version = "\(.*\)"/\1/')
echo "release_version=$VERSION" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
else
echo "release_version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
fi
- name: Update version in build.gradle.kts
if: ${{ github.event.inputs.update_version }}
run: |
sed -i "s/^version = .*/version = \"$RELEASE_VERSION\"/" build.gradle.kts
- name: Update version in app/package.json
if: ${{ github.event.inputs.update_version }}
run: |
jq ".version = \"$RELEASE_VERSION\"" app/package.json > app/package.json.tmp && mv app/package.json.tmp app/package.json
docker:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run production build
env:
GAMEYFIN_KEYSTORE_PASSWORD: ${{ secrets.GAMEYFIN_KEYSTORE_PASSWORD }}
run: ./gradlew clean build -Pvaadin.productionMode=true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
platforms: linux/arm64/v8,linux/amd64
push: true
tags: grimsi/gameyfin:${{ needs.setup.outputs.release_version }}
plugin_api:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build and push Plugin-API
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVENCENTRAL_PASSWORD }}
finalize:
needs: [ docker, plugin_api ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Commit version bump
if: ${{ github.event.inputs.update_version }}
uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: 'chore: release v${{ needs.setup.outputs.release_version }}'
tagging_message: v${{ needs.setup.outputs.release_version }}
- name: Detect prerelease
id: detect_prerelease
run: |
if [[ "${{ needs.setup.outputs.release_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "IS_PRERELEASE=false" >> $GITHUB_ENV
echo "MAKE_LATEST=true" >> $GITHUB_ENV
else
echo "IS_PRERELEASE=true" >> $GITHUB_ENV
echo "MAKE_LATEST=false" >> $GITHUB_ENV
fi
- name: Create GitHub release
if: ${{ github.event.inputs.update_version }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.setup.outputs.release_version }}
prerelease: ${{ env.IS_PRERELEASE }}
make_latest: ${{ env.MAKE_LATEST }}