-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.42 KB
/
release-opencode.yml
File metadata and controls
75 lines (63 loc) · 2.42 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
name: Release opencode package
on:
push:
tags:
- 'opencode-v*'
workflow_dispatch:
inputs:
publish:
description: Publish to npm (unchecked = dry run only)
type: boolean
required: false
default: false
permissions:
contents: read
id-token: write
concurrency:
group: release-opencode
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Read package metadata
id: pkg
run: |
name=$(node -p "require('./opencode/package.json').name")
version=$(node -p "require('./opencode/package.json').version")
echo "name=$name" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Validate release tag matches package version
if: github.event_name == 'push'
run: |
expected="opencode-v${{ steps.pkg.outputs.version }}"
if [ "${GITHUB_REF_NAME}" != "$expected" ]; then
echo "::error title=Tag/version mismatch::Expected tag $expected for version ${{ steps.pkg.outputs.version }}, got ${GITHUB_REF_NAME}."
exit 1
fi
- name: Ensure npm version is not already published
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish)
run: |
if npm view "${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}" version >/dev/null 2>&1; then
echo "::error title=Version already published::${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }} already exists on npm."
exit 1
fi
- name: Validate package contents
working-directory: opencode
run: npm pack --dry-run
- name: Publish to npm
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish)
working-directory: opencode
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry-run summary
if: github.event_name == 'workflow_dispatch' && !inputs.publish
run: |
echo "Dry run complete for ${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}."
echo "Re-run this workflow with publish=true to publish."