From e1026484f913243fe72a567fea61cfa3c3f44a50 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 01:56:57 +0100 Subject: [PATCH 1/8] Update ref from "main" to "master" in release.yml To align with the repository's branch naming convention, this change updates the reference from "main" to "master" in the release.yml file. This ensures consistency and avoids any confusion during the build and release process. --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a79822bcb..5c51b3239 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 with: - ref: main + ref: master # Update latest file with the new version number - name: Update latest file @@ -81,7 +81,7 @@ jobs: with: commit_message: "Update latest file" file_pattern: "latest" - branch: main + branch: master build_ghcr: name: Build Digest for GHCR From b1f62eb129a41501804f4410268c8413c0852828 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 01:59:36 +0100 Subject: [PATCH 2/8] update --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c51b3239..50e1ce750 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,8 +68,6 @@ jobs: # Checkout the repo and the translations branch - name: Checkout uses: actions/checkout@v2 - with: - ref: master # Update latest file with the new version number - name: Update latest file @@ -81,7 +79,6 @@ jobs: with: commit_message: "Update latest file" file_pattern: "latest" - branch: master build_ghcr: name: Build Digest for GHCR From 0d521575bb900896ede754b856dc60c52238c75b Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 02:13:34 +0100 Subject: [PATCH 3/8] Refactor CI workflow with check_changes job and dependencies Previously, the CI workflow did not check if changes only applied to README.md, .github, .vscode, resulting in unnecessary builds. With this commit, a new job named "check_changes" has been added to ensure that the workflow does not run if changes are limited to these files. The "build_ghcr" and "build_dh" jobs have also been updated to depend on the "check_changes" job. This improvement helps optimize the CI process and saves resources. --- .github/workflows/beta-ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/beta-ci.yml b/.github/workflows/beta-ci.yml index 0e6d521dd..d80ab05bb 100644 --- a/.github/workflows/beta-ci.yml +++ b/.github/workflows/beta-ci.yml @@ -27,9 +27,27 @@ jobs: digests_dh digests_ghcr + check_changes: + runs-on: ubuntu-latest + needs: + - clear + steps: + # Do not run if the changes only apply to README.md, .github, .vscode + - name: Check if changes only apply to README.md, .github, .vscode + id: check_changes + run: | + if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then + echo "Changes only apply to README.md, .github, .vscode. Skipping." + exit 0 + else + echo "Changes do not only apply to README.md, .github, .vscode. Continuing." + fi + build_ghcr: name: Build Digest for GHCR runs-on: ubuntu-latest + needs: + - check_changes strategy: fail-fast: false matrix: @@ -154,6 +172,8 @@ jobs: build_dh: name: Build Digest for Docker Hub runs-on: ubuntu-latest + needs: + - check_changes strategy: fail-fast: false matrix: From 76c9c7711ca418f9d60f8479c2de1337d97a71da Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 02:15:22 +0100 Subject: [PATCH 4/8] Add code to checkout the repository during workflow execution This commit adds a step to checkout the repository using the `actions/checkout` action, which will allow subsequent steps to access the repository's code and files. --- .github/workflows/beta-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/beta-ci.yml b/.github/workflows/beta-ci.yml index d80ab05bb..bd56351d2 100644 --- a/.github/workflows/beta-ci.yml +++ b/.github/workflows/beta-ci.yml @@ -32,6 +32,10 @@ jobs: needs: - clear steps: + # Checkout the repo + - name: Checkout + uses: actions/checkout@v4 + # Do not run if the changes only apply to README.md, .github, .vscode - name: Check if changes only apply to README.md, .github, .vscode id: check_changes From 3eade1c4078be8079b840dff4952fc844af45335 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 02:25:54 +0100 Subject: [PATCH 5/8] Refactor GHCR build workflow, add matrix strategy for multiple platforms The GHCR build workflow has been refactored to improve efficiency and support building on multiple platforms. A matrix strategy has been added to configure the build for both linux/amd64 and linux/arm64 architectures. The workflow now checks for changes that only apply to README.md, .github, and .vscode, and will successfully exit if no other changes are detected. --- .github/workflows/beta-ci.yml | 78 ++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/.github/workflows/beta-ci.yml b/.github/workflows/beta-ci.yml index bd56351d2..badf93f46 100644 --- a/.github/workflows/beta-ci.yml +++ b/.github/workflows/beta-ci.yml @@ -27,10 +27,18 @@ jobs: digests_dh digests_ghcr - check_changes: + build_ghcr: + name: Build Digest for GHCR runs-on: ubuntu-latest needs: - clear + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: # Checkout the repo - name: Checkout @@ -41,29 +49,12 @@ jobs: id: check_changes run: | if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then - echo "Changes only apply to README.md, .github, .vscode. Skipping." - exit 0 + echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." + exit 1 else echo "Changes do not only apply to README.md, .github, .vscode. Continuing." fi - build_ghcr: - name: Build Digest for GHCR - runs-on: ubuntu-latest - needs: - - check_changes - strategy: - fail-fast: false - matrix: - platform: - - linux/amd64 - - linux/arm64 - - steps: - # Checkout the repo - - name: Checkout - uses: actions/checkout@v4 - # Get the Metadata from the Docker Image - name: Docker meta id: meta @@ -71,12 +62,6 @@ jobs: with: images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} - # Set up QEMU - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - # with: - # platforms: ${{ matrix.platform }} - # Set up Docker Buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -129,6 +114,17 @@ jobs: - name: Checkout uses: actions/checkout@v2 + # Do not run if the changes only apply to README.md, .github, .vscode + - name: Check if changes only apply to README.md, .github, .vscode + id: check_changes + run: | + if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then + echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." + exit 1 + else + echo "Changes do not only apply to README.md, .github, .vscode. Continuing." + fi + # Get the Release Version from latest - name: Get the Release Version from latest id: get_version @@ -177,7 +173,7 @@ jobs: name: Build Digest for Docker Hub runs-on: ubuntu-latest needs: - - check_changes + - clear strategy: fail-fast: false matrix: @@ -190,6 +186,17 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # Do not run if the changes only apply to README.md, .github, .vscode + - name: Check if changes only apply to README.md, .github, .vscode + id: check_changes + run: | + if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then + echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." + exit 1 + else + echo "Changes do not only apply to README.md, .github, .vscode. Continuing." + fi + # Get the Metadata from the Docker Image - name: Docker meta id: meta @@ -197,12 +204,6 @@ jobs: with: images: ${{ env.DH_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} - # Set up QEMU - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - # with: - # platforms: ${{ matrix.platform }} - # Set up Docker Buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -255,6 +256,17 @@ jobs: - name: Checkout uses: actions/checkout@v2 + # Do not run if the changes only apply to README.md, .github, .vscode + - name: Check if changes only apply to README.md, .github, .vscode + id: check_changes + run: | + if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then + echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." + exit 1 + else + echo "Changes do not only apply to README.md, .github, .vscode. Continuing." + fi + # Get the Release Version from latest - name: Get the Release Version from latest id: get_version From 0a09fb74113731131794eaba94c4f0d4ef02a89d Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 02:45:12 +0100 Subject: [PATCH 6/8] ci.yml: Add paths to ignore in push event This commit adds paths to ignore in the push event to avoid triggering workflows for changes that only apply to README.md, .github, and .vscode directories. --- .github/workflows/beta-ci.yml | 58 +++++++---------------------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/.github/workflows/beta-ci.yml b/.github/workflows/beta-ci.yml index badf93f46..8ccbe5e52 100644 --- a/.github/workflows/beta-ci.yml +++ b/.github/workflows/beta-ci.yml @@ -4,6 +4,10 @@ on: push: branches: - "v3-beta" + paths-ignore: + - "**.md" + - "**/.github/**" + - "**/.vscode/**" workflow_dispatch: {} permissions: @@ -16,7 +20,7 @@ env: IMAGE_TAG: v3-beta jobs: - clear: + before_build: runs-on: ubuntu-latest steps: # Clear the digests from the artifacts @@ -27,11 +31,15 @@ jobs: digests_dh digests_ghcr + # Cancel previous runs of this workflow + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action + build_ghcr: name: Build Digest for GHCR runs-on: ubuntu-latest needs: - - clear + - before_build strategy: fail-fast: false matrix: @@ -44,17 +52,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # Do not run if the changes only apply to README.md, .github, .vscode - - name: Check if changes only apply to README.md, .github, .vscode - id: check_changes - run: | - if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then - echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." - exit 1 - else - echo "Changes do not only apply to README.md, .github, .vscode. Continuing." - fi - # Get the Metadata from the Docker Image - name: Docker meta id: meta @@ -114,17 +111,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - # Do not run if the changes only apply to README.md, .github, .vscode - - name: Check if changes only apply to README.md, .github, .vscode - id: check_changes - run: | - if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then - echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." - exit 1 - else - echo "Changes do not only apply to README.md, .github, .vscode. Continuing." - fi - # Get the Release Version from latest - name: Get the Release Version from latest id: get_version @@ -173,7 +159,7 @@ jobs: name: Build Digest for Docker Hub runs-on: ubuntu-latest needs: - - clear + - before_build strategy: fail-fast: false matrix: @@ -186,17 +172,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # Do not run if the changes only apply to README.md, .github, .vscode - - name: Check if changes only apply to README.md, .github, .vscode - id: check_changes - run: | - if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then - echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." - exit 1 - else - echo "Changes do not only apply to README.md, .github, .vscode. Continuing." - fi - # Get the Metadata from the Docker Image - name: Docker meta id: meta @@ -256,17 +231,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - # Do not run if the changes only apply to README.md, .github, .vscode - - name: Check if changes only apply to README.md, .github, .vscode - id: check_changes - run: | - if [[ "$(git diff --name-only ${{ github.event.before }}..${{ github.sha }} | grep -vE 'README.md|.github|.vscode')" == "" ]]; then - echo "Changes only apply to README.md, .github, .vscode. Successfully exiting." - exit 1 - else - echo "Changes do not only apply to README.md, .github, .vscode. Continuing." - fi - # Get the Release Version from latest - name: Get the Release Version from latest id: get_version From 6956425855dc57c9ee4d48c67247bd7d7616a65c Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 02:47:51 +0100 Subject: [PATCH 7/8] Add concurrency group and cancellation to beta CI workflow This commit adds concurrency group and cancellation to the beta CI workflow. Now, actions in the workflow will be grouped based on the GitHub reference and any in-progress actions will be cancelled before starting a new one. --- .github/workflows/beta-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/beta-ci.yml b/.github/workflows/beta-ci.yml index 8ccbe5e52..629fa9dc0 100644 --- a/.github/workflows/beta-ci.yml +++ b/.github/workflows/beta-ci.yml @@ -19,6 +19,10 @@ env: IMAGE_NAME: wizarrrr/wizarr IMAGE_TAG: v3-beta +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + jobs: before_build: runs-on: ubuntu-latest @@ -31,10 +35,6 @@ jobs: digests_dh digests_ghcr - # Cancel previous runs of this workflow - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action - build_ghcr: name: Build Digest for GHCR runs-on: ubuntu-latest From 448ae5447247dfa5c35b4dd8f660fefa2cb06e50 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Oct 2023 02:58:39 +0100 Subject: [PATCH 8/8] refactor: Simplify release workflow This commit simplifies the release workflow by renaming a job, removing unnecessary steps, and improving the branch and pre-release checks. The workflow now checks if the release is on the master branch and if it is a pre-release before proceeding with the build steps. It also sets the latest tag to the release tag for both GHCR and Docker Hub builds. --- .github/workflows/release.yml | 72 ++++++++++++----------------------- 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50e1ce750..bdd943953 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ env: IMAGE_TAG: latest jobs: - clear: + before_build: runs-on: ubuntu-latest steps: # Clear the digests from the artifacts @@ -26,65 +26,31 @@ jobs: digests_dh digests_ghcr - prerelease: - name: Check if release is not a pre-release - runs-on: ubuntu-latest - needs: - - clear - steps: - # If the release is a pre-release, succeed the job - - name: Check if release is not a pre-release + # Only run the workflow if the release is on the master branch + - name: Check if release is on master branch run: | - if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then - echo "Release is a pre-release. Skipping." - exit 1 - else + if [ "${{ github.event.release.prerelease }}" != true ]; then echo "Release is not a pre-release. Continuing." + else + echo "Release is a pre-release. Skipping workflow." + exit 78 # Exit with a neutral exit code (78) to indicate a skipped workflow. fi - master_branch: - name: Check if release is on master branch - runs-on: ubuntu-latest - needs: - - prerelease - steps: - # If the release is not on the master branch, succeed the job + # Only run the workflow if the release is on the master branch - name: Check if release is on master branch run: | - if [[ "${{ github.event.release.target_commitish }}" != "master" ]]; then - echo "Release is not on master branch. Skipping." - exit 1 + if [ "${{ github.event.release.target_commitish }}" = "master" ]; then + echo "Release is on the master branch." else - echo "Release is on master branch. Continuing." + echo "Release is not on the master branch. Skipping workflow." + exit 78 # Exit with a neutral exit code (78) to indicate a skipped workflow. fi - update_latest: - runs-on: ubuntu-latest - needs: - - master_branch - permissions: - contents: write - steps: - # Checkout the repo and the translations branch - - name: Checkout - uses: actions/checkout@v2 - - # Update latest file with the new version number - - name: Update latest file - run: | - echo "${{ github.event.release.tag_name }}" > latest - - # Commit and push changes - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "Update latest file" - file_pattern: "latest" - build_ghcr: name: Build Digest for GHCR runs-on: ubuntu-latest needs: - - update_latest + - before_build strategy: fail-fast: false matrix: @@ -97,6 +63,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # Set the latest tag to the release tag + - name: Set latest tag + run: | + echo "${{ github.event.release.tag_name }}" > latest + # Get the Metadata from the Docker Image - name: Docker meta id: meta @@ -199,7 +170,7 @@ jobs: name: Build Digest for Docker Hub runs-on: ubuntu-latest needs: - - update_latest + - before_build strategy: fail-fast: false matrix: @@ -212,6 +183,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # Set the latest tag to the release tag + - name: Set latest tag + run: | + echo "${{ github.event.release.tag_name }}" > latest + # Get the Metadata from the Docker Image - name: Docker meta id: meta