forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (81 loc) · 3.37 KB
/
Copy pathoffline-bundle.yml
File metadata and controls
92 lines (81 loc) · 3.37 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
name: Build Offline Bundle
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate next version
id: version
run: |
git fetch --tags
# Get the highest existing version tag (offline-v*)
latest=$(git tag -l 'offline-v*' | sed 's/offline-v//' | sort -n | tail -1)
if [ -z "$latest" ]; then
next=1
else
next=$((latest + 1))
fi
# Get short commit SHA (7 chars)
sha=$(git rev-parse --short=7 HEAD)
echo "version=$next" >> $GITHUB_OUTPUT
echo "tag=offline-v$next" >> $GITHUB_OUTPUT
echo "sha=$sha" >> $GITHUB_OUTPUT
echo "Calculated version: $next (tag: offline-v$next, sha: $sha)"
- uses: ./.github/actions/setup-bun
- name: Download offline dependencies
run: bun run script/download-offline-deps.ts
- name: Build and package bundle
run: bun run script/package-offline-bundle.ts
env:
BUNDLE_VERSION: ${{ steps.version.outputs.version }}
BUNDLE_COMMIT_SHA: ${{ steps.version.outputs.sha }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: opencode-offline-linux-x64-${{ steps.version.outputs.version }}
path: dist/opencode-offline-linux-x64.tar.gz
retention-days: 30
- name: Create version tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.version.outputs.tag }}
git push origin ${{ steps.version.outputs.tag }}
- name: Upload bundle to release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.version.outputs.tag }}"
ASSET="dist/opencode-${{ steps.version.outputs.tag }}-linux-x64.tar.gz"
mv dist/opencode-offline-linux-x64.tar.gz "$ASSET"
if gh release view "$TAG" &>/dev/null; then
gh release upload "$TAG" "$ASSET" --clobber
else
gh release create "$TAG" "$ASSET" --title "$TAG" --generate-notes
fi
- name: Summary
run: |
echo "## Offline Bundle Created" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tag:** \`${{ steps.version.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Bundle Contents" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
tar -tzf dist/opencode-offline-linux-x64.tar.gz | head -50 >> $GITHUB_STEP_SUMMARY
echo "..." >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Manifest" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
cat dist/opencode-offline-linux-x64/manifest.json >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Size:** $(du -h dist/opencode-offline-linux-x64.tar.gz | cut -f1)" >> $GITHUB_STEP_SUMMARY