diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml index c63f78b..056e2c8 100644 --- a/.gitea/workflows/main.yaml +++ b/.gitea/workflows/main.yaml @@ -9,6 +9,10 @@ jobs: release-and-publish: name: Build, Publish Packages (Stable) & Create Release runs-on: ubuntu-latest + env: + CARGO_BINSTALL_VERSION: "1.23.0" + CARGO_DEB_VERSION: "3.8.0" + CARGO_GENERATE_RPM_VERSION: "0.21.0" steps: - name: Checkout Repository uses: actions/checkout@v7 @@ -30,18 +34,44 @@ jobs: restore-keys: | cargo-${{ runner.os }}- - - name: Install Cross-Compilation Toolchains & Dependencies + - name: Install Cross-Compilation Toolchains (apt) run: | sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu gcc-i686-linux-gnu - rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu i686-unknown-linux-gnu - - name: Install Packaging Tools (Prebuilt Binaries) + - name: Ermittle Rust-Version für Rustup-Target-Cache-Key + run: echo "RUST_VERSION=$(rustc --version | awk '{print $2}')" >> "$GITHUB_ENV" + + - name: Cache Rustup Cross-Compilation-Targets + id: cache-rustup-targets + uses: actions/cache@v6 + with: + path: | + ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu + ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu + key: rustup-targets-${{ runner.os }}-${{ env.RUST_VERSION }} + + - name: Add Rust Cross-Compilation Targets + if: steps.cache-rustup-targets.outputs.cache-hit != 'true' + run: rustup target add aarch64-unknown-linux-gnu i686-unknown-linux-gnu + + - name: PATH um Cargo-bin-Verzeichnis ergänzen run: | mkdir -p ~/.cargo/bin - curl -fsSL https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz | tar -xz -C ~/.cargo/bin - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - ~/.cargo/bin/cargo-binstall -y --no-symlinks cargo-deb cargo-generate-rpm + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" + + - name: Cache Packaging-Tools (cargo-binstall, cargo-deb, cargo-generate-rpm) + id: cache-packaging-tools + uses: actions/cache@v6 + with: + path: ~/.cargo/bin + key: packaging-tools-${{ runner.os }}-${{ env.CARGO_BINSTALL_VERSION }}-${{ env.CARGO_DEB_VERSION }}-${{ env.CARGO_GENERATE_RPM_VERSION }} + + - name: Install Packaging Tools (Prebuilt Binaries) + if: steps.cache-packaging-tools.outputs.cache-hit != 'true' + run: | + curl -fsSL "https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-x86_64-unknown-linux-musl.tgz" | tar -xz -C ~/.cargo/bin + ~/.cargo/bin/cargo-binstall -y --no-symlinks "cargo-deb@${CARGO_DEB_VERSION}" "cargo-generate-rpm@${CARGO_GENERATE_RPM_VERSION}" - name: Run Tests run: | diff --git a/.gitea/workflows/testing.yaml b/.gitea/workflows/testing.yaml index a818c08..913b2b9 100644 --- a/.gitea/workflows/testing.yaml +++ b/.gitea/workflows/testing.yaml @@ -9,6 +9,10 @@ jobs: build-and-publish: name: Build, Publish Packages (Testing) & Create Preview Release runs-on: ubuntu-latest + env: + CARGO_BINSTALL_VERSION: "1.23.0" + CARGO_DEB_VERSION: "3.8.0" + CARGO_GENERATE_RPM_VERSION: "0.21.0" steps: - name: Checkout Repository uses: actions/checkout@v7 @@ -30,18 +34,44 @@ jobs: restore-keys: | cargo-${{ runner.os }}- - - name: Install Cross-Compilation Toolchains & Dependencies + - name: Install Cross-Compilation Toolchains (apt) run: | sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu gcc-i686-linux-gnu - rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu i686-unknown-linux-gnu - - name: Install Packaging Tools (Prebuilt Binaries) + - name: Ermittle Rust-Version für Rustup-Target-Cache-Key + run: echo "RUST_VERSION=$(rustc --version | awk '{print $2}')" >> "$GITHUB_ENV" + + - name: Cache Rustup Cross-Compilation-Targets + id: cache-rustup-targets + uses: actions/cache@v6 + with: + path: | + ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-gnu + ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu + key: rustup-targets-${{ runner.os }}-${{ env.RUST_VERSION }} + + - name: Add Rust Cross-Compilation Targets + if: steps.cache-rustup-targets.outputs.cache-hit != 'true' + run: rustup target add aarch64-unknown-linux-gnu i686-unknown-linux-gnu + + - name: PATH um Cargo-bin-Verzeichnis ergänzen run: | mkdir -p ~/.cargo/bin - curl -fsSL https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz | tar -xz -C ~/.cargo/bin - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - ~/.cargo/bin/cargo-binstall -y --no-symlinks cargo-deb cargo-generate-rpm + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" + + - name: Cache Packaging-Tools (cargo-binstall, cargo-deb, cargo-generate-rpm) + id: cache-packaging-tools + uses: actions/cache@v6 + with: + path: ~/.cargo/bin + key: packaging-tools-${{ runner.os }}-${{ env.CARGO_BINSTALL_VERSION }}-${{ env.CARGO_DEB_VERSION }}-${{ env.CARGO_GENERATE_RPM_VERSION }} + + - name: Install Packaging Tools (Prebuilt Binaries) + if: steps.cache-packaging-tools.outputs.cache-hit != 'true' + run: | + curl -fsSL "https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-x86_64-unknown-linux-musl.tgz" | tar -xz -C ~/.cargo/bin + ~/.cargo/bin/cargo-binstall -y --no-symlinks "cargo-deb@${CARGO_DEB_VERSION}" "cargo-generate-rpm@${CARGO_GENERATE_RPM_VERSION}" - name: Run Tests run: | diff --git a/.gitea/workflows/unit-tests.yaml b/.gitea/workflows/unit-tests.yaml new file mode 100644 index 0000000..047eb94 --- /dev/null +++ b/.gitea/workflows/unit-tests.yaml @@ -0,0 +1,38 @@ +name: Unit-Tests + +on: + pull_request: + types: + - opened + - synchronize + - reopened + branches: + - testing + +jobs: + test: + name: Unit-Tests + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v7 + + - name: Install Rust Toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + cache: false + + - name: Cache Cargo-Abhängigkeiten & Build-Artefakte + uses: actions/cache@v6 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-${{ runner.os }}- + + - name: Run Tests + run: cargo test diff --git a/README.md b/README.md index 6948abd..5601ca6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Main Release & Publish](https://gitea.creative-dragonslayer.de/Linuxapps/MirrorPackage/actions/workflows/main.yaml/badge.svg?branch=main)](https://gitea.creative-dragonslayer.de/Linuxapps/MirrorPackage/actions?workflow=main.yaml) +[![Testing Build, Publish & Preview Release](https://gitea.creative-dragonslayer.de/Linuxapps/MirrorPackage/actions/workflows/testing.yaml/badge.svg?branch=testing)](https://gitea.creative-dragonslayer.de/Linuxapps/MirrorPackage/actions?workflow=testing.yaml) + # mirror-package Automatisiertes Werkzeug zum Extrahieren, Herunterladen und Spiegeln vorkompilierter Linux-Pakete aus GitHub-Releases in eine selbstgehostete Gitea- / Forgejo-Paket-Registry. diff --git a/renovate.json b/renovate.json index 481e4f8..f6417c7 100644 --- a/renovate.json +++ b/renovate.json @@ -54,6 +54,34 @@ "depNameTemplate": "trufflesecurity/trufflehog", "datasourceTemplate": "github-releases", "extractVersionTemplate": "^v(?.*)$" + }, + { + "customType": "regex", + "fileMatch": ["^\\.gitea/workflows/.+\\.ya?ml$"], + "matchStrings": [ + "CARGO_BINSTALL_VERSION:\\s*\"(?[^\"]+)\"" + ], + "depNameTemplate": "cargo-bins/cargo-binstall", + "datasourceTemplate": "github-releases", + "extractVersionTemplate": "^v(?.*)$" + }, + { + "customType": "regex", + "fileMatch": ["^\\.gitea/workflows/.+\\.ya?ml$"], + "matchStrings": [ + "CARGO_DEB_VERSION:\\s*\"(?[^\"]+)\"" + ], + "depNameTemplate": "cargo-deb", + "datasourceTemplate": "crate" + }, + { + "customType": "regex", + "fileMatch": ["^\\.gitea/workflows/.+\\.ya?ml$"], + "matchStrings": [ + "CARGO_GENERATE_RPM_VERSION:\\s*\"(?[^\"]+)\"" + ], + "depNameTemplate": "cargo-generate-rpm", + "datasourceTemplate": "crate" } ] }