diff --git a/.github/workflows/docker-develop.yml b/.github/workflows/docker-develop.yml index 73ff724e..847d296e 100644 --- a/.github/workflows/docker-develop.yml +++ b/.github/workflows/docker-develop.yml @@ -6,38 +6,8 @@ on: jobs: - verify-changes: - runs-on: ubuntu-latest - outputs: - build: ${{ steps.list-changes.outputs.build }} - steps: - - - name: Check Out Repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: develop - - - name: Get changes - id: get-changes - run: echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT - - - name: List changed files - id: list-changes - run: | - for file in ${{ steps.get-changes.outputs.files }}; do - if [[ $file =~ ^(defaults|fonts|modules|kometa.py|requirements.txt|.dockerignore|Dockerfile).*$ ]] ; then - echo "$file will trigger docker build" - echo "build=true" >> $GITHUB_OUTPUT - else - echo "$file will not trigger docker build" - fi - done - docker-build: runs-on: ubuntu-latest - needs: [ verify-changes ] - if: needs.verify-changes.outputs.build == 'true' steps: - name: Check Out Repo @@ -103,8 +73,8 @@ jobs: commit-notification: runs-on: ubuntu-latest - needs: [ docker-build, verify-changes ] - if: ${{ success() && needs.verify-changes.outputs.build == 'true' }} + needs: [ docker-build ] + if: ${{ success() }} steps: - name: Send Discord Commit Notification diff --git a/.github/workflows/docker-nightly.yml b/.github/workflows/docker-nightly.yml new file mode 100644 index 00000000..334764ca --- /dev/null +++ b/.github/workflows/docker-nightly.yml @@ -0,0 +1,74 @@ +name: Docker Nightly Release + +on: + workflow_run: + workflows: ["Release New Version"] + types: + - completed + +jobs: + + docker-build: + runs-on: ubuntu-latest + steps: + + - name: Check Out Repo + uses: actions/checkout@v4 + with: + ref: nightly + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push + id: docker_build + uses: docker/build-push-action@v5 + with: + context: ./ + file: ./Dockerfile + build-args: | + "BRANCH_NAME=nightly" + platforms: linux/amd64,linux/arm64 + push: true + tags: kometateam/kometa:nightly + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Discord Success Notification + uses: Kometa-Team/discord-notifications@master + if: success() + with: + webhook_id_token: ${{ secrets.BUILD_WEBHOOK }} + title: "${{ vars.REPO_NAME }} nightly: ${{ vars.TEXT_SUCCESS }}" + url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/actions/runs/${{ github.run_id }} + color: ${{ vars.COLOR_SUCCESS }} + username: ${{ vars.BOT_NAME }} + avatar_url: ${{ vars.BOT_IMAGE }} + author: ${{ vars.DOCKER_NAME }} + author_icon_url: ${{ vars.DOCKER_IMAGE }} + + - name: Discord Failure Notification + uses: Kometa-Team/discord-notifications@master + if: failure() + with: + webhook_id_token: ${{ secrets.BUILD_WEBHOOK }} + message: ${{ vars.BUILD_FAILURE_ROLE }} + title: "${{ vars.REPO_NAME }} nightly: ${{ vars.TEXT_FAILURE }}" + url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/actions/runs/${{ github.run_id }} + color: ${{ vars.COLOR_FAILURE }} + username: ${{ vars.BOT_NAME }} + avatar_url: ${{ vars.BOT_IMAGE }} + author: ${{ vars.DOCKER_NAME }} + author_icon_url: ${{ vars.DOCKER_IMAGE }} \ No newline at end of file diff --git a/.github/workflows/merge-develop.yml b/.github/workflows/merge-develop.yml index 9979c658..8f655bb6 100644 --- a/.github/workflows/merge-develop.yml +++ b/.github/workflows/merge-develop.yml @@ -19,9 +19,64 @@ jobs: uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} - ref: nightly + ref: develop fetch-depth: 0 - - name: Push Nightly into Develop + - name: Fast Forward Develop run: | - git push origin refs/heads/nightly:refs/heads/develop + value=$(cat VERSION) + develop_hash=$(git rev-parse HEAD) + next_build="${{ vars.DEVELOP_BUILD }}" + + if [[ "$value" == *"-"* ]]; then + develop_build="$((${value#*-build}))" + else + develop_build="0" + fi + + git checkout origin/nightly + + value=$(cat VERSION) + + if [[ "$value" == *"-"* ]]; then + nightly_build="$((${value#*-build}))" + else + nightly_build="0" + fi + + echo "DEVELOP_BUILD: '${develop_build}'" + echo "NIGHTLY_BUILD: '${nightly_build}'" + echo "NEXT_BUILD: '${next_build}'" + + if (( next_build <= develop_build )); then + echo "::error::NEXT_BUILD variable (${next_build}) must be greater than DEVELOP_BUILD (${develop_build})" + exit 1 + elif (( next_build > nightly_build )); then + echo "::error::NEXT_BUILD variable (${next_build}) must be less than or equal to NIGHTLY_BUILD (${nightly_build})" + exit 1 + fi + + while : ; do + value=$(cat VERSION) + + if [[ "$value" == *"-"* ]]; then + loop_build="$((${value#*-build}))" + else + loop_build="1" + fi + + if [[ "$next_build" == "$loop_build" ]]; then + hash=$(git rev-parse HEAD) + echo "Fast Forwarding Develop to ${hash}" + git push origin ${hash}:refs/heads/develop + break + fi + + git checkout HEAD^ + + hash=$(git rev-parse HEAD) + if [[ "$develop_hash" == "$hash" ]]; then + echo "::error::No Commit found to Fast Forward" + exit 1 + fi + done diff --git a/.github/workflows/merge-master.yml b/.github/workflows/merge-master.yml index 7cf95be4..4adf1e78 100644 --- a/.github/workflows/merge-master.yml +++ b/.github/workflows/merge-master.yml @@ -1,4 +1,4 @@ -name: Merge Develop into Master +name: Release New Version on: workflow_dispatch: @@ -19,9 +19,28 @@ jobs: uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} - ref: develop + ref: nightly fetch-depth: 0 - - name: Push Develop into Master + - name: Create Release Commit and Synchronize Branches run: | - git push origin refs/heads/develop:refs/heads/master + value=$(cat VERSION) + version="${value%-build*}" + next_version="${{ vars.NEXT_VERSION }}" + echo "CURRENT_VERSION: '${version}'" + echo "NEXT_VERSION: '${next_version}'" + + if [[ "$version" == "$next_version" ]]; then + echo "::error::NEXT_VERSION variable (${next_version}) must be incremented" + exit 1 + fi + + echo "$next_version" > "VERSION" + + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add VERSION + git commit -m "Kometa Release ${next_version}" + git push origin nightly + git push origin refs/heads/nightly:refs/heads/develop + git push origin refs/heads/nightly:refs/heads/main diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index e7dfd9b2..ff1c72ba 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -36,20 +36,15 @@ jobs: run: | value=$(cat VERSION) old_msg=$(git log -1 HEAD --pretty=format:%s) + version="${value%-build*}" if [[ "$value" == *"-"* ]]; then - version="${value%-build*}" build_value="$((${value#*-build} + 1))" - new_value="${version}-build${build_value}" - elif [[ "$value" == *"!"* ]]; then - version="${value%!*}" - new_value="${version}" - build_value="${new_value}" else - version="${value%-build*}" build_value="1" - new_value="${version}-build${build_value}" fi + + new_value="${version}-build${build_value}" new_msg="[${build_value}] ${old_msg}" echo "version=${version}" >> $GITHUB_OUTPUT @@ -164,16 +159,16 @@ jobs: commit-notification: runs-on: ubuntu-latest needs: [ increment-version, verify-changes, docker-build ] - if: ${{ success() && needs.increment-version.outputs.build == 'true' }} + if: ${{ success() && needs.verify-changes.outputs.build == 'true' }} steps: - name: Send Discord Commit Notification uses: Kometa-Team/discord-notifications@master with: webhook_id_token: ${{ secrets.NIGHTLY_WEBHOOK }} - title: Kometa ${{ needs.verify-changes.outputs.version }} Build ${{ needs.verify-changes.outputs.build-value }} - url: https://github.com/Kometa-Team/Kometa/commit/${{ needs.verify-changes.outputs.commit-hash }} - description: ${{ needs.verify-changes.outputs.commit-msg }} + title: Kometa ${{ needs.increment-version.outputs.version }} Build ${{ needs.increment-version.outputs.build-value }} + url: https://github.com/Kometa-Team/Kometa/commit/${{ needs.increment-version.outputs.commit-hash }} + description: ${{ needs.increment-version.outputs.commit-msg }} message: "<@&967002147520675840> - An update to Kometa has now been published and is available to users of the **nightly** branch." color: ${{ vars.COLOR_SUCCESS }} username: ${{ vars.BOT_NAME }} diff --git a/VERSION b/VERSION index 20d31607..452c9371 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.1-build33 +2.0.1-build34