Skip to content

Commit 4a26bb7

Browse files
committed
Add pull request checks and tag-based GitHub releases
1 parent cf5e12c commit 4a26bb7

11 files changed

Lines changed: 1444 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, master]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
checks:
18+
name: Checks (Node ${{ matrix.node }})
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 15
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
node: [22, 24]
25+
steps:
26+
- name: Check out code
27+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28+
with:
29+
persist-credentials: false
30+
- name: Set up Node.js
31+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
32+
with:
33+
node-version: ${{ matrix.node }}
34+
cache: npm
35+
- name: Install dependencies
36+
run: npm ci
37+
- name: Lint, typecheck, test, and build
38+
run: npm run check
39+
- name: Verify package installation
40+
run: npm run package:check

‎.github/workflows/release.yml‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v[0-9]*', '[0-9]*']
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: release-${{ github.ref }}
12+
cancel-in-progress: false
13+
14+
jobs:
15+
package:
16+
name: Build and verify release package
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
outputs:
20+
prerelease: ${{ steps.version.outputs.prerelease }}
21+
filename: ${{ steps.package.outputs.filename }}
22+
steps:
23+
- name: Check out the tag
24+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
with:
26+
persist-credentials: false
27+
- name: Set up Node.js
28+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
29+
with:
30+
node-version: 22
31+
cache: npm
32+
- name: Install dependencies
33+
run: npm ci
34+
- name: Set package version from tag
35+
id: version
36+
env:
37+
RELEASE_TAG: ${{ github.ref_name }}
38+
run: node scripts/release-version.mjs "$RELEASE_TAG"
39+
- name: Lint, typecheck, test, and build
40+
run: npm run check
41+
- name: Pack and verify installation
42+
id: package
43+
run: npm run package:check -- "$RUNNER_TEMP/release"
44+
- name: Upload verified release files
45+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
46+
with:
47+
name: release-package
48+
path: |
49+
${{ runner.temp }}/release/*.tgz
50+
${{ runner.temp }}/release/*.sha256
51+
if-no-files-found: error
52+
retention-days: 7
53+
54+
publish:
55+
name: Publish GitHub Release
56+
needs: package
57+
runs-on: ubuntu-latest
58+
timeout-minutes: 5
59+
permissions:
60+
contents: write
61+
steps:
62+
- name: Download verified release files
63+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
64+
with:
65+
name: release-package
66+
path: release
67+
- name: Create release with package and checksum
68+
working-directory: release
69+
env:
70+
GH_TOKEN: ${{ github.token }}
71+
RELEASE_TAG: ${{ github.ref_name }}
72+
PRERELEASE: ${{ needs.package.outputs.prerelease }}
73+
PACKAGE_FILE: ${{ needs.package.outputs.filename }}
74+
run: |
75+
sha256sum --check "$PACKAGE_FILE.sha256"
76+
args=(--repo "$GITHUB_REPOSITORY" --verify-tag --title "$RELEASE_TAG" --generate-notes)
77+
if [[ "$PRERELEASE" == "true" ]]; then
78+
args+=(--prerelease --latest=false)
79+
fi
80+
gh release create "$RELEASE_TAG" "$PACKAGE_FILE" "$PACKAGE_FILE.sha256" "${args[@]}"

‎README.md‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ Nothing needs to be published to npm. `$HOME` expands to your home directory.
2121

2222
## Install from a .tgz package
2323

24-
1. Download/copy the archive to the machine running OpenCode 2 and install it:
24+
1. Download/copy the archive to the machine running OpenCode 2 and install it
25+
(replace `VERSION` with the downloaded version):
2526

2627
```bash
27-
npm install --global --prefix "$HOME/.local" "$HOME/Downloads/opencode2-automation-0.5.0-beta.5.tgz"
28+
npm install --global --prefix "$HOME/.local" "$HOME/Downloads/opencode2-automation-VERSION.tgz"
2829
```
2930

3031
`postinstall` registers both the plugin and TUI automatically. No `sudo`,
@@ -274,7 +275,30 @@ npm run check
274275
npm pack
275276
```
276277

277-
`npm run check` runs type checking, tests, and a build. `npm pack` creates
278-
`opencode2-automation-0.5.0-beta.5.tgz` with compiled code and the installer;
278+
Use Node 22.13+ or 24+ for development. `npm run check` runs ESLint, type checking,
279+
tests, and a build. `npm run package:check` additionally packs and verifies a
280+
global install in a temporary directory, including `postinstall` and the CLI.
281+
`npm pack` creates
282+
`opencode2-automation-<version>.tgz` using the version in `package.json`, with compiled code and the installer;
279283
copy it to another machine and follow the `.tgz` instructions above.
280284
`private: true` prevents accidental npm publication.
285+
286+
## GitHub Actions and releases
287+
288+
- **Pull requests:** CI runs ESLint, type checking, unit tests, a build, and a
289+
package installation check on Node 22 and 24. Pushes to `main`/`master` also run CI.
290+
- **Releases:** push a SemVer tag to build and publish a GitHub Release with the
291+
`.tgz` and SHA-256 checksum. The tag controls the package version; there is no
292+
need to edit `package.json` first. Tests and package installation must pass.
293+
294+
After the workflow files are committed and pushed, tag the commit you want to release:
295+
296+
```bash
297+
git tag v0.5.0
298+
git push origin v0.5.0
299+
```
300+
301+
Use your next unused version. Both `v0.5.0` and `0.5.0` are accepted; a suffix
302+
such as `v0.6.0-beta.1` creates a prerelease. Version changes happen only in CI,
303+
without a version commit or npm publication. Releases use the built-in
304+
`GITHUB_TOKEN`; no npm token or extra secret is needed.

‎eslint.config.mjs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import js from "@eslint/js";
2+
import ts from "typescript-eslint";
3+
import globals from "globals";
4+
5+
export default ts.config(
6+
{ ignores: ["dist/**", "node_modules/**", ".opencode/**"] },
7+
js.configs.recommended,
8+
...ts.configs.recommended,
9+
{
10+
languageOptions: { globals: globals.node },
11+
rules: {
12+
"no-empty": ["error", { allowEmptyCatch: true }],
13+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", caughtErrors: "none" }],
14+
},
15+
},
16+
// SDK mocks intentionally model only the fields used by each test.
17+
{ files: ["test/**/*.ts"], rules: { "@typescript-eslint/no-explicit-any": "off" } },
18+
);

0 commit comments

Comments
 (0)