From 6d19a435a8cf08ae52a984180892bb738a8b3812 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 09:50:32 +0100 Subject: [PATCH 01/10] Update CD workflow; remove step and adjust if condition --- .github/workflows/cd.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f7b5a0e..4766beb 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -86,21 +86,19 @@ jobs: - name: Upload Binary uses: actions/upload-artifact@v4 with: - name: ${{ matrix.target }}-${{ github.run_number }} + name: git-ai-${{ matrix.target }} if-no-files-found: error path: | bin/git-ai bin/git-ai-hook - - name: Print the artifact URL - run: echo ${{ steps.upload-artifact.outputs.artifact-url }} - release: needs: build runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: github.event.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 + - name: Setup Rust uses: actions-rs/toolchain@v1 with: @@ -121,7 +119,7 @@ jobs: cargo bump patch --git-tag cargo check - - name: Include the version bump in the commit message + - name: Commit Version Bump run: git commit -a --amend --no-edit - name: Publish to crates.io @@ -129,3 +127,13 @@ jobs: - name: Push to origin run: git push origin HEAD --tags + + # precompile: + # if: github.event.ref == 'refs/tags/*' + # needs: release + # runs-on: ubuntu-latest + # steps: + # - name: Release + # uses: softprops/action-gh-release@v2 + # with: + # files: Release.txt From c5b9e3b34d575464cebbff9328c1d90017080723 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:48:28 +0100 Subject: [PATCH 02/10] Revise CD workflow: adjust artifact management, upload process --- .github/workflows/cd.yml | 66 ++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4766beb..822c7c8 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,7 +19,10 @@ env: CARGO_TERM_COLOR: always jobs: - build: + artifact: + runs-on: ${{ matrix.os }} + continue-on-error: false + if: github.event.ref != 'refs/tags/*' strategy: matrix: include: @@ -31,19 +34,9 @@ jobs: target: aarch64-apple-darwin - os: ubuntu-latest target: x86_64-unknown-linux-musl - runs-on: ${{ matrix.os }} - continue-on-error: false steps: - uses: actions/checkout@v4 - - name: Ensure no changes (1) - run: git diff --exit-code --quiet && cargo check - continue-on-error: true - - - name: Git status - if: failure() - run: git status && exit 1 - - name: Setup Rust uses: actions-rs/toolchain@v1 with: @@ -67,23 +60,15 @@ jobs: sudo apt-get update sudo apt-get install -y pkg-config libssl-dev - - name: Ensure no changes - run: git diff --exit-code --quiet && cargo check - - - name: Git status - if: failure() - run: git status && exit 1 - - name: Build for target - run: cargo build -Z unstable-options --profile dev --artifact-dir bin --target ${{ matrix.target }} - - - name: List all targets run: | - ls -halt bin/ - pwd - realpath bin/ + cargo build \ + -Z unstable-options \ + --profile dev \ + --artifact-dir bin \ + --target ${{ matrix.target }} - - name: Upload Binary + - name: Upload and compress artifacts uses: actions/upload-artifact@v4 with: name: git-ai-${{ matrix.target }} @@ -93,9 +78,8 @@ jobs: bin/git-ai-hook release: - needs: build runs-on: ubuntu-latest - if: github.event.ref == 'refs/heads/main' + needs: artifact steps: - uses: actions/checkout@v4 @@ -128,12 +112,22 @@ jobs: - name: Push to origin run: git push origin HEAD --tags - # precompile: - # if: github.event.ref == 'refs/tags/*' - # needs: release - # runs-on: ubuntu-latest - # steps: - # - name: Release - # uses: softprops/action-gh-release@v2 - # with: - # files: Release.txt + precompile: + if: github.event.ref == 'refs/tags/*' + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + run: gh run download {{ github.run_id }} + + - name: Zip each downloaded directory + run: | + for dir in $(ls -d git-ai-*); do + tar -czf ${dir}.tar.gz ${dir} + done + + - name: Uploads compressed artifacts + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ github.event.ref }} + fail_on_unmatched_files: true + files: git-ai-*.tar.gz From e58d45dd0859058476cff6c80ee2406115b629bb Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:49:01 +0100 Subject: [PATCH 03/10] Trigger actions on all tag events in CD workflow --- .github/workflows/cd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 822c7c8..07c0e02 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "**" pull_request: concurrency: From 92bf3cc403a3c866ff97cc96d2cb10c909aa8edc Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:50:54 +0100 Subject: [PATCH 04/10] Fix concurrency cancel flag and add packages permission --- .github/workflows/cd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 07c0e02..bc3aac7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,10 +10,11 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false + cancel-in-progress: true permissions: contents: write + packages: write env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From ddae41f9d008eb1672692c6f0ffbff26a466ed5c Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:53:13 +0100 Subject: [PATCH 05/10] Fix Git tag reference in CD workflow file --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index bc3aac7..1255ddf 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -131,6 +131,6 @@ jobs: - name: Uploads compressed artifacts uses: softprops/action-gh-release@v2 with: - tag_name: v${{ github.event.ref }} + tag_name: v${{ github.event.ref_name }} fail_on_unmatched_files: true files: git-ai-*.tar.gz From a4f09d62d530d2f140826bc23f2d49f290613942 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:53:30 +0100 Subject: [PATCH 06/10] Fix syntax in GitHub Actions expression --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1255ddf..82bd46e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -120,7 +120,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download all artifacts - run: gh run download {{ github.run_id }} + run: gh run download ${{ github.run_id }} - name: Zip each downloaded directory run: | From 4443c7fdcba675b6799bda1cb693a1dc1efa2f45 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:55:41 +0100 Subject: [PATCH 07/10] Fix tag reference condition in GitHub Actions workflow --- .github/workflows/cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 82bd46e..b6ca35b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -25,7 +25,7 @@ jobs: artifact: runs-on: ${{ matrix.os }} continue-on-error: false - if: github.event.ref != 'refs/tags/*' + if: ! startsWith(github.ref, 'refs/tags/') strategy: matrix: include: @@ -116,7 +116,7 @@ jobs: run: git push origin HEAD --tags precompile: - if: github.event.ref == 'refs/tags/*' + if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - name: Download all artifacts From 0d8cc3eb72381b04e606003ccc5bf1301f5637b6 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:00:08 +0100 Subject: [PATCH 08/10] Add condition to execute only on 'main' branch --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b6ca35b..8402e6a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -83,6 +83,7 @@ jobs: release: runs-on: ubuntu-latest needs: artifact + if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 From 7dc336772e4dce8f0915245f63e3c3fffd25a218 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:05:27 +0100 Subject: [PATCH 09/10] Fix syntax error in GitHub Actions 'if' condition --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 8402e6a..d11a324 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -25,7 +25,7 @@ jobs: artifact: runs-on: ${{ matrix.os }} continue-on-error: false - if: ! startsWith(github.ref, 'refs/tags/') + if: ${{ !startsWith(github.ref, 'refs/tags/') }} strategy: matrix: include: From 3650d4edad2db49ddf125d22f700783b17838733 Mon Sep 17 00:00:00 2001 From: Linus Oleander <220827+oleander@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:08:05 +0100 Subject: [PATCH 10/10] Fix condition and tag syntax in CD workflow --- .github/workflows/cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d11a324..f593074 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -83,7 +83,7 @@ jobs: release: runs-on: ubuntu-latest needs: artifact - if: github.ref == 'refs/heads/main' + if: ${{ github.ref == 'refs/heads/main' }} steps: - uses: actions/checkout@v4 @@ -132,6 +132,6 @@ jobs: - name: Uploads compressed artifacts uses: softprops/action-gh-release@v2 with: - tag_name: v${{ github.event.ref_name }} + tag_name: v${{ github.ref_name }} fail_on_unmatched_files: true files: git-ai-*.tar.gz