diff --git a/.github/dependabot.yml b/.github/dependabot.yml index af9bc970..e53f57f7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,6 @@ enable-beta-ecosystems: true updates: - package-ecosystem: "gradle" directory: "/" - target-branch: "dev" schedule: interval: "daily" time: "10:00" @@ -19,7 +18,6 @@ updates: - package-ecosystem: "github-actions" directory: "/" - target-branch: "dev" schedule: interval: "daily" time: "10:00" @@ -31,7 +29,6 @@ updates: - package-ecosystem: "docker" directory: "/" - target-branch: "dev" schedule: interval: "daily" time: "10:00" diff --git a/.github/workflows/check_tokens.yml b/.github/workflows/check_tokens.yml index 1b2f5133..bd3e8247 100644 --- a/.github/workflows/check_tokens.yml +++ b/.github/workflows/check_tokens.yml @@ -10,15 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - ref: dev - name: Check tokens and update if necessary run: | #!/bin/bash CRUNCHYROLL_RS_TOKEN=$(curl 'https://raw.githubusercontent.com/crunchy-labs/crunchyroll-rs/master/src/crunchyroll.rs' | grep -oP 'Basic \K[^\\"]*' | head -n 1) - SHIKKANIME_TOKEN=$(curl 'https://raw.githubusercontent.com/Shikkanime/core/dev/src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt' | grep -oP 'Basic \K[^\\"]*' | head -n 1) + SHIKKANIME_TOKEN=$(cat 'src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt' | grep -oP 'Basic \K[^\\"]*' | head -n 1) if [ "$CRUNCHYROLL_RS_TOKEN" != "$SHIKKANIME_TOKEN" ]; then echo "Tokens are different. Updating Shikkanime token..." diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d8639e10..78645623 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -15,11 +15,9 @@ on: push: branches: - master - - dev pull_request: branches: - master - - dev schedule: - cron: '33 14 * * 5' diff --git a/.github/workflows/development_workflow.yml b/.github/workflows/development_workflow.yml index 2165ef33..95fe212b 100644 --- a/.github/workflows/development_workflow.yml +++ b/.github/workflows/development_workflow.yml @@ -4,14 +4,14 @@ on: pull_request: types: [opened, synchronize, reopened, edited] push: - branches: [dev] + branches: [master] env: JAVA_VERSION: 21 jobs: validate-pr-title: - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' runs-on: ubuntu-latest steps: - name: PR Conventional Commit Validation @@ -29,28 +29,30 @@ jobs: java-version: ${{ env.JAVA_VERSION }} distribution: 'corretto' - name: Analyze push - if: github.event_name == 'push' && github.ref == 'refs/heads/dev' + if: github.event_name == 'push' env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} run: ./gradlew sonar --info - name: Analyse pull request - if: github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'master' && github.actor != 'dependabot[bot]' + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} run: ./gradlew sonar --info -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} -Dsonar.qualitygate.wait=true - - name: Analyse pull request - if: github.event_name == 'pull_request' && (github.event.pull_request.base.ref == 'master' || github.actor == 'dependabot[bot]') + - name: Build and test + if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' run: ./gradlew clean test --info test-compose: + runs-on: ubuntu-latest + needs: [test] strategy: fail-fast: false matrix: - platform: [linux/amd64, linux/arm64/v8] - runs-on: ubuntu-latest - needs: [test] + platform: [linux/amd64, linux/arm64] + build_version: [slim, full] + steps: - uses: actions/checkout@v4 - name: Set up JDK ${{ env.JAVA_VERSION }} @@ -62,9 +64,11 @@ jobs: run: gradle clean installDist -x test - name: Set up QEMU uses: docker/setup-qemu-action@v3 + with: + platforms: ${{ matrix.platform }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Start services - run: docker compose up -d --build --wait + run: BUILD_VERSION=${{ matrix.build_version }} docker compose up -d --build --wait - name: Stop services run: docker compose down \ No newline at end of file diff --git a/.github/workflows/release_workflow.yml b/.github/workflows/release_workflow.yml index 42c0ae2e..991e1de3 100644 --- a/.github/workflows/release_workflow.yml +++ b/.github/workflows/release_workflow.yml @@ -1,28 +1,69 @@ name: Release workflow on: - push: - branches: - - master + workflow_dispatch: # Allows manual triggering env: - REGISTRY_IMAGE: registry.shikkanime.fr:5000/shikkanime-core + JAVA_VERSION: 21 + REGISTRY_IMAGE: ${{ vars.DOCKERHUB_USERNAME }}/shikkanime-core jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: 'corretto' + - name: Build and test + run: ./gradlew clean test --info + + upgrade-version: + runs-on: ubuntu-latest + + outputs: + v-version: ${{ steps.version.outputs.v-version }} + + steps: + - uses: actions/checkout@v4 + + - name: Get next version + uses: reecetech/version-increment@2024.4.4 + id: version + with: + scheme: conventional_commits + docker: runs-on: ubuntu-latest + needs: [test, upgrade-version] + strategy: + fail-fast: false + matrix: + build_version: [slim, full] steps: - uses: actions/checkout@v4 - - name: Set up JDK 21 + # Pull the latest commits + - name: Pull latest commits + run: git pull + + - name: Set up JDK ${{ env.JAVA_VERSION }} uses: actions/setup-java@v4 with: - java-version: 21 + java-version: ${{ env.JAVA_VERSION }} distribution: 'corretto' - - name: Build - run: gradle clean installDist + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=raw,value=${{ matrix.build_version }} + type=raw,value=${{ matrix.build_version }}-${{ needs.upgrade-version.outputs.v-version }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -33,41 +74,79 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: registry.shikkanime.fr:5000 - username: ziedelth - password: ${{ secrets.REGISTRY_PASSWORD }} + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Update version in build.gradle.kts + run: | + #!/bin/bash + PROJECT_VERSION=$(cat 'build.gradle.kts' | grep -oP 'version = "\K[^\\"]*' | head -n 1) + + # Update the file + sed -i "s|$PROJECT_VERSION|${{ needs.upgrade-version.outputs.v-version }}|g" build.gradle.kts + + - name: Build + run: gradle clean installDist - name: Build docker file uses: docker/build-push-action@v6 with: context: . + file: Dockerfile + build-args: BUILD_VERSION=${{ matrix.build_version }} + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.build_version }} + cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.build_version }},mode=max push: true - tags: ${{ env.REGISTRY_IMAGE }}:latest,${{ env.REGISTRY_IMAGE }}:${{ steps.version.outputs.v-version }} - platforms: linux/arm64/v8 - cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache - cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache - - name: Get next version - uses: reecetech/version-increment@2024.4.4 - id: version + push-commit: + runs-on: ubuntu-latest + needs: [upgrade-version, docker] + steps: + - uses: actions/checkout@v4 with: - scheme: conventional_commits + persist-credentials: false + fetch-depth: 0 - - name: Generate Git Tag - id: generate_tag + - name: Update version in build.gradle.kts run: | - NEW_TAG="${{ steps.version.outputs.v-version }}" - echo "Generated new tag: $NEW_TAG" - echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV + #!/bin/bash + PROJECT_VERSION=$(cat 'build.gradle.kts' | grep -oP 'version = "\K[^\\"]*' | head -n 1) + + # Update the file + sed -i "s|$PROJECT_VERSION|${{ needs.upgrade-version.outputs.v-version }}|g" build.gradle.kts + + # Set up Git + git config user.name Ziedelth + git config user.email ${{ secrets.USER_EMAIL }} + + # Commit the changes + git add build.gradle.kts + git commit -m "Update version to ${{ needs.upgrade-version.outputs.v-version }}" + + - name: Push changes + uses: ad-m/github-push-action@v0.8.0 + with: + github_token: ${{ secrets.USER_TOKEN }} + branch: ${{ github.ref }} + force: true + + push-tag: + runs-on: ubuntu-latest + needs: [upgrade-version, push-commit] + + steps: + - uses: actions/checkout@v4 + + # Pull the latest commits + - name: Pull latest commits + run: git pull - name: Push Git Tag run: | git config user.name "GitHub Actions" git config user.email "github-actions@users.noreply.github.com" - git tag $NEW_TAG - git push origin $NEW_TAG - - - uses: marvinpinto/action-automatic-releases@v1.2.1 - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false \ No newline at end of file + git tag ${{ needs.upgrade-version.outputs.v-version }} + git push origin ${{ needs.upgrade-version.outputs.v-version }} \ No newline at end of file diff --git a/.github/workflows/update-gradle-wrapper.yml b/.github/workflows/update-gradle-wrapper.yml index a84ba934..917a9108 100644 --- a/.github/workflows/update-gradle-wrapper.yml +++ b/.github/workflows/update-gradle-wrapper.yml @@ -18,6 +18,4 @@ jobs: - name: Update Gradle Wrapper uses: gradle-update/update-gradle-wrapper-action@v1.0.20 with: - reviewers: Ziedelth - base-branch: dev - target-branch: dev \ No newline at end of file + reviewers: Ziedelth \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 96bc3467..1ebf5070 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,19 @@ ARG JAVA_VERSION=21 +ARG PLAYWRIGHT_VERSION=1.46.1 +ARG BUILD_VERSION=full FROM amazoncorretto:${JAVA_VERSION} AS java -FROM mcr.microsoft.com/playwright:v1.46.1-jammy + +# Base image for full version +FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-jammy AS full + +# Base image for slim version +FROM node:20-bookworm-slim AS slim +ARG PLAYWRIGHT_VERSION +RUN npx -y playwright@${PLAYWRIGHT_VERSION} install --with-deps firefox + +# Select the base image based on the build argument +FROM ${BUILD_VERSION} ARG JAVA_VERSION COPY --from=java /usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto /usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto @@ -9,10 +21,11 @@ COPY --from=java /usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto /usr/lib/jvm/ ENV LANG=C.UTF-8 \ JAVA_HOME=/usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto \ TZ=Europe/Paris \ - DEBIAN_FRONTEND=noninteractive + DEBIAN_FRONTEND=noninteractive \ + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 # Install necessary packages and set timezone -RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata libopencv-dev fonts-dejavu \ +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata libopencv-dev fonts-dejavu curl \ && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* \ && ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata diff --git a/build.gradle.kts b/build.gradle.kts index dfc3669b..9a237bab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,7 +41,7 @@ plugins { } group = "fr.shikkanime" -version = "0.0.1" +version = "0.2.15" application { mainClass.set("fr.shikkanime.ApplicationKt") diff --git a/docker-compose.yml b/docker-compose.yml index b94f66db..6227e40b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: shikkanime-db: image: postgres:16-alpine @@ -11,7 +10,10 @@ services: healthcheck: test: [ "CMD", "pg_isready", "-U", "postgres" ] shikkanime-core: - build: . + build: + context: . + args: + BUILD_VERSION: ${BUILD_VERSION:-full} # Use the environment variable or default to 'full ports: - "37100:37100" restart: on-failure