Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 31c8b8f05f | |||
| 8f1881ae9a | |||
| d702f74582 | |||
| 0984773711 |
@@ -81,6 +81,17 @@ jobs:
|
||||
docker push "$IMAGE_NAME:$VERSION"
|
||||
docker push "$IMAGE_NAME:latest"
|
||||
|
||||
- name: Build binary
|
||||
run: |
|
||||
set -eu
|
||||
# Extract binary from the already-built image (no Go toolchain needed)
|
||||
docker create --name extract_tmp "$IMAGE_NAME:$VERSION"
|
||||
docker cp extract_tmp:/app/sub2api /tmp/sub2api
|
||||
docker rm extract_tmp
|
||||
cd /tmp
|
||||
tar -czf "sub2api_linux_amd64.tar.gz" sub2api
|
||||
sha256sum "sub2api_linux_amd64.tar.gz" > checksums.txt
|
||||
|
||||
- name: Create Gitea release
|
||||
env:
|
||||
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
@@ -88,9 +99,25 @@ jobs:
|
||||
set -eu
|
||||
BODY="Docker image: ${IMAGE_NAME}:${VERSION}"
|
||||
PAYLOAD=$(printf '{"tag_name":"%s","target_commitish":"%s","name":"Sub2API %s","body":"%s","draft":false,"prerelease":false}' "$TAG" "$(git rev-parse HEAD)" "$VERSION" "$BODY")
|
||||
curl -fsS \
|
||||
RELEASE_ID=$(curl -fsS \
|
||||
-X POST \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$PAYLOAD" \
|
||||
"$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases" || true
|
||||
"$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
||||
|
||||
# Upload binary archive
|
||||
curl -fsS \
|
||||
-X POST \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @/tmp/sub2api_linux_amd64.tar.gz \
|
||||
"$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases/${RELEASE_ID}/assets?name=sub2api_linux_amd64.tar.gz"
|
||||
|
||||
# Upload checksums
|
||||
curl -fsS \
|
||||
-X POST \
|
||||
-H "Authorization: token ${RELEASE_TOKEN}" \
|
||||
-H "Content-Type: text/plain" \
|
||||
--data-binary @/tmp/checksums.txt \
|
||||
"$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases/${RELEASE_ID}/assets?name=checksums.txt"
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.1.140
|
||||
0.1.148
|
||||
|
||||
@@ -62,16 +62,16 @@ func (p *GeminiTokenProvider) GetAccessToken(ctx context.Context, account *Accou
|
||||
|
||||
cacheKey := GeminiTokenCacheKey(account)
|
||||
|
||||
// 1) Try cache first.
|
||||
if p.tokenCache != nil {
|
||||
// 1) Try cache first — skip if token is already expired or within refresh skew.
|
||||
expiresAt := account.GetCredentialAsTime("expires_at")
|
||||
needsRefresh := expiresAt == nil || time.Until(*expiresAt) <= geminiTokenRefreshSkew
|
||||
if !needsRefresh && p.tokenCache != nil {
|
||||
if token, err := p.tokenCache.GetAccessToken(ctx, cacheKey); err == nil && strings.TrimSpace(token) != "" {
|
||||
return token, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Refresh if needed (pre-expiry skew).
|
||||
expiresAt := account.GetCredentialAsTime("expires_at")
|
||||
needsRefresh := expiresAt == nil || time.Until(*expiresAt) <= geminiTokenRefreshSkew
|
||||
|
||||
if needsRefresh && p.refreshAPI != nil && p.executor != nil {
|
||||
result, err := p.refreshAPI.RefreshIfNeeded(ctx, account, p.executor, geminiTokenRefreshSkew)
|
||||
|
||||
@@ -22,11 +22,11 @@ import (
|
||||
const (
|
||||
updateCacheKey = "update_check_cache"
|
||||
updateCacheTTL = 1200 // 20 minutes
|
||||
defaultGitHubRepo = "man209111-cpu/sub2api"
|
||||
defaultGitHubRepo = "kgod/sub2api"
|
||||
|
||||
// Security: allowed download domains for updates
|
||||
allowedDownloadHost = "github.com"
|
||||
allowedAssetHost = "objects.githubusercontent.com"
|
||||
allowedDownloadHost = "git.jianshixingqiu.com"
|
||||
allowedAssetHost = "8.138.12.104"
|
||||
|
||||
// Security: max download size (500MB)
|
||||
maxDownloadSize = 500 * 1024 * 1024
|
||||
|
||||
Reference in New Issue
Block a user