diff --git a/.github/workflows/repack.yml b/.github/workflows/repack.yml index 9ce0604..feeab55 100644 --- a/.github/workflows/repack.yml +++ b/.github/workflows/repack.yml @@ -1,6 +1,8 @@ name: Verify and repack official OpenCode on: workflow_dispatch: + push: + tags: ['v*'] permissions: contents: read jobs: @@ -24,3 +26,28 @@ jobs: name: opencode-${{ matrix.target }} path: release/* if-no-files-found: error + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: repack + runs-on: ubuntu-24.04 + permissions: + contents: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: opencode-* + merge-multiple: true + path: release + - name: Attach the repacked builds to the release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + TAG: ${{ github.ref_name }} + run: | + # The release may already exist (published at the merge): attach to it + # rather than failing, whichever came first. + if gh release view "$TAG" >/dev/null 2>&1; then + gh release upload "$TAG" release/* --clobber + else + gh release create "$TAG" release/* --title "OpenCode $TAG" --notes "Official OpenCode binaries, checksum-verified and repacked. See the repository README for upstream provenance." + fi diff --git a/extension.toml b/extension.toml index 5354f72..1b85069 100644 --- a/extension.toml +++ b/extension.toml @@ -1,7 +1,7 @@ [extension] id = "opencode" name = "OpenCode" -version = "0.1.0" +version = "0.1.1" node = ">=0.4.3" publisher = "aurelio" summary = "OpenCode with the machine's sign-in and private agent configuration." diff --git a/scripts/repack.py b/scripts/repack.py index 2f088a9..7f76ef6 100644 --- a/scripts/repack.py +++ b/scripts/repack.py @@ -77,7 +77,10 @@ def main(): parser.add_argument('--output', type=Path, default=Path('release')) args = parser.parse_args() if args.download: - with urllib.request.urlopen(pin['platforms'][args.target]['url'], timeout=120) as response: + # opencode.ai answers Python's default User-Agent with 403. + request = urllib.request.Request(pin['platforms'][args.target]['url'], + headers={'User-Agent': 'pointman-opencode-repack'}) + with urllib.request.urlopen(request, timeout=120) as response: data = response.read() else: data = args.archive.read_bytes()