From 79bc4df08a9ed7b8dc41f3aa9d94890f1eda9dd4 Mon Sep 17 00:00:00 2001 From: nicos_backbase Date: Mon, 13 Oct 2025 18:52:43 +0200 Subject: [PATCH 1/3] ci: improve maintainability and speed --- .github/workflows/ci.yml | 37 ++---- .github/workflows/release.yml | 206 +++++++++++++++++++++------------- CHANGELOG.md | 19 ---- Cargo.toml | 2 +- 4 files changed, 140 insertions(+), 124 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 720113e..0d0b990 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,20 +23,14 @@ jobs: uses: actions/checkout@v5 - name: Install Rust - uses: dtolnay/rust-toolchain@master + uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - name: Cache dependencies - uses: actions/cache@v4 + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.rust }} - name: Check formatting run: cargo fmt --all -- --check @@ -50,7 +44,12 @@ jobs: run: cargo test --verbose - name: Build + run: cargo build --verbose + if: matrix.rust != 'stable' + + - name: Build (release) run: cargo build --verbose --release + if: matrix.rust == 'stable' security_audit: name: Security Audit @@ -63,15 +62,7 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + uses: Swatinem/rust-cache@v2 - name: Install cargo-audit run: cargo install cargo-audit @@ -130,15 +121,9 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Cache dependencies - uses: actions/cache@v4 + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.os }} - name: Build run: cargo build --verbose --release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec07092..a9c3071 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,15 +28,7 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + uses: Swatinem/rust-cache@v2 - name: Run tests run: cargo test --all-features @@ -144,12 +136,12 @@ jobs: - os: ubuntu-latest target: x86_64-unknown-linux-gnu suffix: "" - # - os: ubuntu-latest - # target: x86_64-unknown-linux-musl - # suffix: "" - # - os: windows-latest - # target: x86_64-pc-windows-msvc - # suffix: ".exe" + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + suffix: "" + - os: windows-latest + target: x86_64-pc-windows-msvc + suffix: ".exe" - os: macos-latest target: x86_64-apple-darwin suffix: "" @@ -161,10 +153,6 @@ jobs: - name: Checkout code uses: actions/checkout@v5 - - name: Update Cargo.toml version - run: | - sed -i.bak 's/^version = ".*"/version = "${{ needs.semantic-version.outputs.version }}"/' Cargo.toml && rm Cargo.toml.bak - - name: Install Rust uses: dtolnay/rust-toolchain@stable with: @@ -175,15 +163,9 @@ jobs: run: sudo apt-get update && sudo apt-get install -y musl-tools - name: Cache dependencies - uses: actions/cache@v4 + uses: Swatinem/rust-cache@v2 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.target }} - name: Build for ${{ matrix.target }} run: | @@ -196,7 +178,12 @@ jobs: - name: Strip binary (Unix only) if: matrix.suffix == '' - run: strip repos-${{ matrix.target }} + run: | + if [[ "${{ runner.os }}" == "macOS" ]]; then + strip -x repos-${{ matrix.target }} + else + strip repos-${{ matrix.target }} + fi - name: Create archive shell: bash @@ -204,8 +191,9 @@ jobs: staging="repos-${{ needs.semantic-version.outputs.version }}-${{ matrix.target }}" mkdir -p "$staging" - cp target/${{ matrix.target }}/release/repos${{ matrix.suffix }} "$staging/" - cp README.md LICENSE* "$staging/" 2>/dev/null || true + cp repos-${{ matrix.target }}${{ matrix.suffix }} "$staging/" + cp README.md "$staging/" 2>/dev/null || true + if [ -f LICENSE ]; then cp LICENSE "$staging/"; fi tar czf "$staging.tar.gz" "$staging" echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV @@ -218,9 +206,64 @@ jobs: tag_name: ${{ needs.semantic-version.outputs.version_tag }} files: ${{ env.ASSET }} + build-universal-macos: + name: Build Universal macOS Binary + needs: [semantic-version, create-release] + runs-on: macos-latest + if: needs.semantic-version.outputs.changed == 'true' && github.event_name == 'push' + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-apple-darwin,aarch64-apple-darwin + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + with: + key: universal-macos + + - name: Build for both architectures + run: | + cargo build --release --target x86_64-apple-darwin + cargo build --release --target aarch64-apple-darwin + + - name: Create universal binary + run: | + lipo -create \ + target/x86_64-apple-darwin/release/repos \ + target/aarch64-apple-darwin/release/repos \ + -output repos-universal-apple-darwin + + # Verify the universal binary + lipo -info repos-universal-apple-darwin + + - name: Strip universal binary + run: strip -x repos-universal-apple-darwin + + - name: Create universal archive + run: | + staging="repos-${{ needs.semantic-version.outputs.version }}-universal-apple-darwin" + mkdir -p "$staging" + cp repos-universal-apple-darwin "$staging/repos" + cp README.md "$staging/" 2>/dev/null || true + if [ -f LICENSE ]; then cp LICENSE "$staging/"; fi + tar czf "$staging.tar.gz" "$staging" + echo "UNIVERSAL_ASSET=$staging.tar.gz" >> $GITHUB_ENV + + - name: Upload Universal macOS Asset + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.semantic-version.outputs.version_tag }} + files: ${{ env.UNIVERSAL_ASSET }} + publish-crate: name: Publish to crates.io - needs: [semantic-version, create-release, build-release] + needs: [semantic-version, create-release, build-release, build-universal-macos] runs-on: ubuntu-latest if: needs.semantic-version.outputs.changed == 'true' && github.event_name == 'push' && !contains(needs.semantic-version.outputs.version, 'alpha') && !contains(needs.semantic-version.outputs.version, 'beta') && !contains(needs.semantic-version.outputs.version, 'rc') @@ -236,53 +279,60 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Cache dependencies - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + uses: Swatinem/rust-cache@v2 - name: Publish to crates.io run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} -# docker-release: -# name: Build and Push Docker Image -# needs: create-release -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v5 - -# - 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.DOCKER_USERNAME }} -# password: ${{ secrets.DOCKER_PASSWORD }} - -# - name: Extract metadata -# id: meta -# uses: docker/metadata-action@v5 -# with: -# images: ${{ secrets.DOCKER_USERNAME }}/repos -# tags: | -# type=ref,event=tag -# type=semver,pattern={{version}} -# type=semver,pattern={{major}}.{{minor}} -# type=semver,pattern={{major}} - -# - name: Build and push Docker image -# uses: docker/build-push-action@v5 -# with: -# context: . -# platforms: linux/amd64,linux/arm64 -# push: true -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} -# cache-from: type=gha -# cache-to: type=gha,mode=max + docker-release: + name: Build and Push Docker Image + needs: [semantic-version, create-release] + runs-on: ubuntu-latest + if: needs.semantic-version.outputs.changed == 'true' && github.event_name == 'push' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - 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.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + if: secrets.DOCKER_USERNAME != null && secrets.DOCKER_PASSWORD != null + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ secrets.DOCKER_USERNAME }}/repos + ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}},value=${{ needs.semantic-version.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.semantic-version.outputs.version }} + type=semver,pattern={{major}},value=${{ needs.semantic-version.outputs.version }} + type=raw,value=latest + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + provenance: false + sbom: false + build-args: | + VERSION=${{ needs.semantic-version.outputs.version }} diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 72e852a..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,19 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.1.0] - 2025-07-14 - -### New - -- Initial release of repos -- Repository cloning functionality -- Command execution across multiple repositories -- Pull request creation support -- Repository management (clone, run, pr, rm, init) -- Configuration-based repository management -- Tag-based repository filtering -- Parallel execution support diff --git a/Cargo.toml b/Cargo.toml index e2faf7e..c6badcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "repos" -version = "0.1.0" +version = "0.0.2" edition = "2024" [dependencies] From 097e4d1c45c596d88448f406704e2a8942569296 Mon Sep 17 00:00:00 2001 From: nicos_backbase Date: Mon, 13 Oct 2025 18:55:03 +0200 Subject: [PATCH 2/3] ci: fix reference to secrets --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a9c3071..c2fca44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -300,7 +300,7 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - if: secrets.DOCKER_USERNAME != null && secrets.DOCKER_PASSWORD != null + if: ${{ secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' }} - name: Log in to GitHub Container Registry uses: docker/login-action@v3 From 33703dc421da61aa0fd1033b5f060f02b8ed5291 Mon Sep 17 00:00:00 2001 From: nicos_backbase Date: Mon, 13 Oct 2025 19:00:16 +0200 Subject: [PATCH 3/3] ci: fix reference to secrets --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2fca44..d1e2db4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -300,7 +300,6 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - if: ${{ secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' }} - name: Log in to GitHub Container Registry uses: docker/login-action@v3