mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-10 06:03:50 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9716d1a351 | ||
|
|
d5a2556768 | ||
|
|
e7f1921620 | ||
|
|
7ea6ae6de5 | ||
|
|
d7c2e6436c | ||
|
|
fde61ee07d | ||
|
|
c4de3961a0 | ||
|
|
404c574c2c | ||
|
|
6d4df20f54 | ||
|
|
7b3745d095 | ||
|
|
f9aa516da7 |
11
.github/actions/build-image/Dockerfile
vendored
Normal file
11
.github/actions/build-image/Dockerfile
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM --platform=$BUILDPLATFORM alpine AS builder
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG TARGETOS
|
||||||
|
|
||||||
|
COPY binaries/* /
|
||||||
|
RUN mv cup-$TARGETOS-$TARGETARCH cup
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=builder /cup /cup
|
||||||
|
ENTRYPOINT ["/cup"]
|
||||||
51
.github/actions/build-image/action.yml
vendored
Normal file
51
.github/actions/build-image/action.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
name: Build Image
|
||||||
|
inputs:
|
||||||
|
tags:
|
||||||
|
description: "Docker image tags"
|
||||||
|
required: true
|
||||||
|
gh-token:
|
||||||
|
description: "Github token"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download binaries
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: .
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
ghcr.io/sergi0g/cup
|
||||||
|
tags: ${{ inputs.tags }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: sergi0g
|
||||||
|
password: ${{ inputs.gh-token }}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./.github/actions/build-image/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
34
.github/workflows/nightly.yml
vendored
34
.github/workflows/nightly.yml
vendored
@@ -62,38 +62,24 @@ jobs:
|
|||||||
cup-linux-arm64
|
cup-linux-arm64
|
||||||
|
|
||||||
build-image:
|
build-image:
|
||||||
needs: get-tag
|
needs:
|
||||||
|
- get-tag
|
||||||
|
- build-binaries
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/build-image
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
tags: |
|
||||||
username: ${{ github.repository_owner }}
|
${{ needs.get-tag.outputs.tag }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
gh-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push image
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64, linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ghcr.io/sergi0g/cup:${{ needs.get-tag.outputs.tag }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
nightly-release:
|
nightly-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [build-binaries, get-tag]
|
needs:
|
||||||
|
- build-binaries
|
||||||
|
- build-image
|
||||||
steps:
|
steps:
|
||||||
- name: Download binaries
|
- name: Download binaries
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|||||||
31
.github/workflows/release.yml
vendored
31
.github/workflows/release.yml
vendored
@@ -60,34 +60,19 @@ jobs:
|
|||||||
cup-linux-arm64
|
cup-linux-arm64
|
||||||
|
|
||||||
build-image:
|
build-image:
|
||||||
needs: get-tag
|
needs:
|
||||||
|
- get-tag
|
||||||
|
- build-binaries
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/build-image
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
tags: |
|
||||||
username: ${{ github.repository_owner }}
|
${{ needs.get-tag.outputs.tag }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
latest
|
||||||
|
gh-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push image
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64, linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ghcr.io/sergi0g/cup:${{ needs.get-tag.outputs.tag }},ghcr.io/sergi0g/cup:latest
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
1167
Cargo.lock
generated
1167
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@@ -1,15 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cup"
|
name = "cup"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.7", features = ["derive"] }
|
clap = { version = "4.5.7", features = ["derive"] }
|
||||||
indicatif = { version = "0.17.8", optional = true }
|
indicatif = { version = "0.17.8", optional = true }
|
||||||
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
|
||||||
xitca-web = { version = "0.5.0", optional = true }
|
xitca-web = { version = "0.6.2", optional = true }
|
||||||
liquid = { version = "0.26.6", optional = true }
|
liquid = { version = "0.26.6", optional = true }
|
||||||
bollard = "0.16.1"
|
bollard = "0.18.1"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
http-auth = { version = "0.1.9", default-features = false }
|
http-auth = { version = "0.1.9", default-features = false }
|
||||||
termsize = { version = "0.1.8", optional = true }
|
termsize = { version = "0.1.8", optional = true }
|
||||||
@@ -17,11 +17,11 @@ regex = { version = "1.10.5", default-features = false, features = ["perf"] }
|
|||||||
chrono = { version = "0.4.38", default-features = false, features = ["std", "alloc", "clock"], optional = true }
|
chrono = { version = "0.4.38", default-features = false, features = ["std", "alloc", "clock"], optional = true }
|
||||||
reqwest = { version = "0.12.7", default-features = false, features = ["rustls-tls"] }
|
reqwest = { version = "0.12.7", default-features = false, features = ["rustls-tls"] }
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
reqwest-retry = "0.6.1"
|
reqwest-retry = "0.7.0"
|
||||||
reqwest-middleware = "0.3.3"
|
reqwest-middleware = "0.3.3"
|
||||||
rustc-hash = "2.0.0"
|
rustc-hash = "2.0.0"
|
||||||
http-link = "1.0.1"
|
http-link = "1.0.1"
|
||||||
itertools = "0.13.0"
|
itertools = "0.14.0"
|
||||||
serde_json = "1.0.133"
|
serde_json = "1.0.133"
|
||||||
serde = "1.0.215"
|
serde = "1.0.215"
|
||||||
tokio-cron-scheduler = { version = "0.13.0", default-features = false, optional = true }
|
tokio-cron-scheduler = { version = "0.13.0", default-features = false, optional = true }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ RUN ~/.bun/bin/bun install
|
|||||||
RUN ~/.bun/bin/bun run build
|
RUN ~/.bun/bin/bun run build
|
||||||
|
|
||||||
### Build Cup ###
|
### Build Cup ###
|
||||||
FROM rust:1.80.1-alpine AS build
|
FROM rust:1-alpine AS build
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
RUN apk add musl-dev
|
RUN apk add musl-dev
|
||||||
|
|||||||
27
src/check.rs
27
src/check.rs
@@ -120,6 +120,16 @@ pub async fn get_updates(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|image| &image.parts.registry)
|
.map(|image| &image.parts.registry)
|
||||||
.unique()
|
.unique()
|
||||||
|
.filter(|®istry| match ctx.config.registries.get(registry) {
|
||||||
|
Some(config) => {
|
||||||
|
if config.ignore {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => true,
|
||||||
|
})
|
||||||
.collect::<Vec<&String>>();
|
.collect::<Vec<&String>>();
|
||||||
|
|
||||||
// Create request client. All network requests share the same client for better performance.
|
// Create request client. All network requests share the same client for better performance.
|
||||||
@@ -138,7 +148,7 @@ pub async fn get_updates(
|
|||||||
|
|
||||||
// Retrieve an authentication token (if required) for each registry.
|
// Retrieve an authentication token (if required) for each registry.
|
||||||
let mut tokens: FxHashMap<&str, Option<String>> = FxHashMap::default();
|
let mut tokens: FxHashMap<&str, Option<String>> = FxHashMap::default();
|
||||||
for registry in registries {
|
for registry in registries.clone() {
|
||||||
let credentials = if let Some(registry_config) = ctx.config.registries.get(registry) {
|
let credentials = if let Some(registry_config) = ctx.config.registries.get(registry) {
|
||||||
®istry_config.authentication
|
®istry_config.authentication
|
||||||
} else {
|
} else {
|
||||||
@@ -163,24 +173,11 @@ pub async fn get_updates(
|
|||||||
|
|
||||||
ctx.logger.debug(format!("Tokens: {:?}", tokens));
|
ctx.logger.debug(format!("Tokens: {:?}", tokens));
|
||||||
|
|
||||||
let ignored_registries = ctx
|
|
||||||
.config
|
|
||||||
.registries
|
|
||||||
.iter()
|
|
||||||
.filter_map(|(registry, registry_config)| {
|
|
||||||
if registry_config.ignore {
|
|
||||||
Some(registry)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<&String>>();
|
|
||||||
|
|
||||||
let mut handles = Vec::with_capacity(images.len());
|
let mut handles = Vec::with_capacity(images.len());
|
||||||
|
|
||||||
// Loop through images check for updates
|
// Loop through images check for updates
|
||||||
for image in &images {
|
for image in &images {
|
||||||
let is_ignored = ignored_registries.contains(&&image.parts.registry)
|
let is_ignored = !registries.contains(&&image.parts.registry)
|
||||||
|| ctx
|
|| ctx
|
||||||
.config
|
.config
|
||||||
.images
|
.images
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ impl Client {
|
|||||||
let message = format!("{} {}: Connection timed out!", method, url);
|
let message = format!("{} {}: Connection timed out!", method, url);
|
||||||
self.ctx.logger.warn(&message);
|
self.ctx.logger.warn(&message);
|
||||||
Err(message)
|
Err(message)
|
||||||
|
} else if error.is_middleware() {
|
||||||
|
let message = format!("{} {}: Connection failed after 3 retries!", method, url);
|
||||||
|
self.ctx.logger.warn(&message);
|
||||||
|
Err(message)
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
"{} {}: Unexpected error: {}",
|
"{} {}: Unexpected error: {}",
|
||||||
|
|||||||
Reference in New Issue
Block a user