This repository was archived by the owner on Feb 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (94 loc) · 4.12 KB
/
opencode-repackager.yml
File metadata and controls
113 lines (94 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Repackage OpenCode Windows Executables
on:
schedule:
# Runs daily at 2:00 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.1.13), or leave empty for latest'
required: false
type: string
jobs:
repackage:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get latest version if not specified
id: get_version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "Fetching latest version..."
VERSION=$(curl -s "https://api.github.com/repos/anomalyco/opencode/releases/latest" | jq -r '.tag_name')
echo "Found latest version: $VERSION"
else
VERSION="${{ github.event.inputs.version }}"
echo "Using specified version: $VERSION"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if version already exists
id: check_version
run: |
VERSION_EXISTS=$(curl -s "https://api.github.com/repos/${{ github.repository_owner }}/opencode-cli/releases/tags/${{ steps.get_version.outputs.version }}" | jq -r '.tag_name // "NOT_FOUND"')
if [ "$VERSION_EXISTS" = "NOT_FOUND" ]; then
echo "exists=false" >> $GITHUB_OUTPUT
echo "Version does not exist locally, proceeding..."
else
echo "exists=true" >> $GITHUB_OUTPUT
echo "Version already exists locally, skipping."
fi
- name: Download and repackage executables
if: steps.check_version.outputs.exists == 'false'
id: repackage
run: |
mkdir -p downloads output
VERSION="${{ steps.get_version.outputs.version }}"
REPO_URL="https://github.com/anomalyco/opencode/releases/download"
# ZIP files configuration
# Format: zip_filename:path_in_zip:output_filename
ZIPS=(
"opencode-windows-x64-baseline.zip:opencode.exe:opencode-baseline.exe"
"opencode-windows-x64.zip:opencode.exe:opencode.exe"
)
# Download and extract
echo "Downloading from version: $VERSION"
for config in "${ZIPS[@]}"; do
IFS=':' read -r zip_name path_in_zip output_name <<< "$config"
DOWNLOAD_URL="$REPO_URL/$VERSION/$zip_name"
echo "Downloading: $zip_name from $DOWNLOAD_URL"
curl -L -f -o "downloads/$zip_name" "$DOWNLOAD_URL" || {
echo "❌ Failed to download: $zip_name"
exit 1
}
# Extract
echo "Extracting: $zip_name"
unzip -q "downloads/$zip_name" -d "downloads/$zip_name.extracted"
# Debug: show available exe files
echo "Available files in $zip_name:"
find "downloads/$zip_name.extracted/" -type f \( -name "*.exe" -o -name "opencode*" \) | head -20
# Find and copy file
if [ -f "downloads/$zip_name.extracted/$path_in_zip" ]; then
cp "downloads/$zip_name.extracted/$path_in_zip" "output/$output_name"
echo "✓ $zip_name -> $output_name"
else
echo "❌ Path not found: $path_in_zip in $zip_name"
exit 1
fi
done
echo "Final output:"
ls -lah output/
- name: Create Release
if: steps.check_version.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.version }}
files: output/*
body: "These executables were automatically repackaged from OpenCode [${{ steps.get_version.outputs.version }}](https://github.com/anomalyco/opencode/releases/tag/${{ steps.get_version.outputs.version }})."
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up
if: always()
run: |
rm -rf downloads output