diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e727c04 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,82 @@ +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: + release: + runs-on: ubuntu-latest + permissions: + contents: write + env: + RELEASE_VERSION: ${{ github.event.inputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Needed for git tag + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - 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_ENV + else + 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 + + - 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:$RELEASE_VERSION + + - name: Commit version bump + if: ${{ github.event.inputs.update_version }} + uses: stefanzweifel/git-auto-commit-action@v6 + with: + commit_message: 'chore: release $RELEASE_VERSION' + tagging_message: 'v$RELEASE_VERSION'