Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
5430437bfd | |
|
|
0d72c189b3 | |
|
|
39ef2f59b6 | |
|
|
48a03f3376 | |
|
|
9fd284e556 | |
|
|
f03e09dca2 |
|
|
@ -6,57 +6,86 @@ on:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
release:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- goos: darwin
|
|
||||||
goarch: arm64
|
|
||||||
- goos: darwin
|
|
||||||
goarch: amd64
|
|
||||||
- goos: linux
|
|
||||||
goarch: amd64
|
|
||||||
- goos: linux
|
|
||||||
goarch: arm64
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
- name: Install Go
|
||||||
with:
|
|
||||||
go-version: '1.22'
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
env:
|
|
||||||
GOOS: ${{ matrix.goos }}
|
|
||||||
GOARCH: ${{ matrix.goarch }}
|
|
||||||
run: |
|
run: |
|
||||||
|
curl -fsSL https://go.dev/dl/go1.22.12.linux-amd64.tar.gz | tar -C /usr/local -xz
|
||||||
|
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Build all platforms
|
||||||
|
run: |
|
||||||
|
export PATH="/usr/local/go/bin:$PATH"
|
||||||
|
export GOTOOLCHAIN=local
|
||||||
cd cli
|
cd cli
|
||||||
go build -ldflags="-s -w" -o ../auth-rt-${{ matrix.goos }}-${{ matrix.goarch }} .
|
for pair in darwin/arm64 darwin/amd64 linux/amd64 linux/arm64; do
|
||||||
|
os="${pair%/*}"
|
||||||
- name: Upload artifact
|
arch="${pair#*/}"
|
||||||
uses: actions/upload-artifact@v4
|
echo "Building auth-rt-${os}-${arch}..."
|
||||||
with:
|
GOOS="$os" GOARCH="$arch" CGO_ENABLED=0 go build -ldflags="-s -w" -o "../auth-rt-${os}-${arch}" .
|
||||||
name: auth-rt-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
||||||
path: auth-rt-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
||||||
|
|
||||||
release:
|
|
||||||
needs: build
|
|
||||||
runs-on: docker
|
|
||||||
steps:
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Create release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
files: auth-rt-*
|
|
||||||
generate_release_notes: true
|
|
||||||
|
|
||||||
- name: Update latest tag
|
|
||||||
run: |
|
|
||||||
# Also upload to "latest" release for install.sh --download
|
|
||||||
for f in auth-rt-*; do
|
|
||||||
echo "Uploading $f to latest release..."
|
|
||||||
done
|
done
|
||||||
|
ls -lh ../auth-rt-*
|
||||||
|
|
||||||
|
- name: Create release and upload binaries
|
||||||
|
env:
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
API_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||||
|
run: |
|
||||||
|
json_get() { node -e "process.stdout.write(String(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).$1 || ''))"; }
|
||||||
|
|
||||||
|
# Create release
|
||||||
|
RELEASE_ID=$(curl -s -X POST "$API_URL/releases" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"auth-rt $TAG\"}" \
|
||||||
|
| json_get id)
|
||||||
|
|
||||||
|
echo "Created release ID: $RELEASE_ID"
|
||||||
|
|
||||||
|
# Upload each binary
|
||||||
|
for f in auth-rt-*; do
|
||||||
|
echo "Uploading $f..."
|
||||||
|
curl -s -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$f" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@$f"
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
# Maintain "latest" release
|
||||||
|
LATEST_ID=$(curl -s "$API_URL/releases/tags/latest" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" | json_get id)
|
||||||
|
|
||||||
|
if [ -n "$LATEST_ID" ]; then
|
||||||
|
# Delete old assets
|
||||||
|
ASSET_IDS=$(curl -s "$API_URL/releases/$LATEST_ID/assets" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
| node -e "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).forEach(a=>console.log(a.id))")
|
||||||
|
for aid in $ASSET_IDS; do
|
||||||
|
curl -s -X DELETE "$API_URL/releases/$LATEST_ID/assets/$aid" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN"
|
||||||
|
done
|
||||||
|
curl -s -X PATCH "$API_URL/releases/$LATEST_ID" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"body\":\"auth-rt latest (from $TAG)\"}"
|
||||||
|
else
|
||||||
|
LATEST_ID=$(curl -s -X POST "$API_URL/releases" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"tag_name":"latest","name":"latest","body":"auth-rt latest","prerelease":true}' \
|
||||||
|
| json_get id)
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in auth-rt-*; do
|
||||||
|
curl -s -X POST "$API_URL/releases/$LATEST_ID/assets?name=$f" \
|
||||||
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Done. Release $TAG + latest updated."
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
module github.com/agent-skills/auth-rt
|
module github.com/agent-skills/auth-rt
|
||||||
|
|
||||||
go 1.25.7
|
go 1.22
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,18 @@ import * as path from 'path';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
|
||||||
const home = process.env.HOME || os.homedir();
|
const home = process.env.HOME || os.homedir();
|
||||||
|
|
||||||
|
// ── session ID (Langfuse tracing) ──
|
||||||
|
// Priority: SKILL_SESSION_ID env > auto-generate
|
||||||
|
const SESSION_ID = process.env.SKILL_SESSION_ID || (() => {
|
||||||
|
const ts = new Date();
|
||||||
|
const pad = (n: number) => String(n).padStart(2, '0');
|
||||||
|
const tsPart = `${ts.getFullYear()}${pad(ts.getMonth()+1)}${pad(ts.getDate())}-${pad(ts.getHours())}${pad(ts.getMinutes())}${pad(ts.getSeconds())}`;
|
||||||
|
const rand = Math.random().toString(36).slice(2, 6);
|
||||||
|
return `skill-${tsPart}-${rand}`;
|
||||||
|
})();
|
||||||
|
process.env.SKILL_SESSION_ID = SESSION_ID;
|
||||||
|
|
||||||
const AUTH_RT_BIN = process.env.AUTH_RT_BIN
|
const AUTH_RT_BIN = process.env.AUTH_RT_BIN
|
||||||
|| (() => {
|
|| (() => {
|
||||||
// Check if auth-rt is in PATH
|
// Check if auth-rt is in PATH
|
||||||
|
|
@ -43,6 +55,20 @@ export interface SessionResponse {
|
||||||
hookToken?: string;
|
hookToken?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ClientConfig {
|
||||||
|
clientId: string;
|
||||||
|
name: string;
|
||||||
|
status: string;
|
||||||
|
metadata: {
|
||||||
|
provider?: {
|
||||||
|
api_key?: string;
|
||||||
|
base_url?: string;
|
||||||
|
model?: string;
|
||||||
|
};
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export interface SkillClientOptions {
|
export interface SkillClientOptions {
|
||||||
apiBase?: string;
|
apiBase?: string;
|
||||||
dryRun?: boolean;
|
dryRun?: boolean;
|
||||||
|
|
@ -79,6 +105,13 @@ export class SkillClient {
|
||||||
return JSON.parse(runCli('session'));
|
return JSON.parse(runCli('session'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async clientConfig(): Promise<ClientConfig> {
|
||||||
|
if (this.dryRun) {
|
||||||
|
return { clientId: '<dry-run>', name: '<dry-run>', status: 'active', metadata: {} };
|
||||||
|
}
|
||||||
|
return JSON.parse(runCli('client-config'));
|
||||||
|
}
|
||||||
|
|
||||||
async get(urlPath: string): Promise<ApiResponse> {
|
async get(urlPath: string): Promise<ApiResponse> {
|
||||||
return this.request('GET', urlPath);
|
return this.request('GET', urlPath);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue