-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (102 loc) · 3.27 KB
/
Copy pathrelease.yml
File metadata and controls
121 lines (102 loc) · 3.27 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
114
115
116
117
118
119
120
121
name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
custom_version:
description: 'Custom version (overrides version_type if provided)'
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Run tests (if any)
run: npm test --if-present
- name: Check TypeScript types
run: npx tsc --noEmit
- name: Verify dist directory
run: |
if [ ! -d "dist" ]; then
echo "Error: dist directory not found"
exit 1
fi
if [ ! -f "dist/index.js" ]; then
echo "Error: dist/index.js not found"
exit 1
fi
if [ ! -f "dist/index.d.ts" ]; then
echo "Error: dist/index.d.ts not found"
exit 1
fi
echo "Build verification successful!"
- name: Check package contents
run: npm pack --dry-run
- name: Bump version (custom)
if: github.event.inputs.custom_version != ''
run: |
npm version ${{ github.event.inputs.custom_version }} --no-git-tag-version
echo "NEW_VERSION=${{ github.event.inputs.custom_version }}" >> $GITHUB_ENV
- name: Bump version (automatic)
if: github.event.inputs.custom_version == ''
run: |
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version)
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Commit version bump
run: |
git add package.json
git commit -m "Bump version to ${NEW_VERSION}"
- name: Create and push tag
run: |
git tag ${NEW_VERSION}
git push origin main --tags
- name: Publish to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_VERSION }}
release_name: Release ${{ env.NEW_VERSION }}
body: |
Release ${{ env.NEW_VERSION }}
## Changes
- Package published to NPM: https://www.npmjs.com/package/@dbcode/vscode-api
## Installation
```bash
npm install @dbcode/vscode-api@${{ env.NEW_VERSION }}
```
draft: false
prerelease: false