Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 11 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
205 changes: 127 additions & 78 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ""
Expand All @@ -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:
Expand All @@ -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: |
Expand All @@ -196,16 +178,22 @@ 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
run: |
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
Expand All @@ -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')

Expand All @@ -236,53 +279,59 @@ 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 }}

- 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 }}
19 changes: 0 additions & 19 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "repos"
version = "0.1.0"
version = "0.0.2"
edition = "2024"

[dependencies]
Expand Down
Loading