-
Notifications
You must be signed in to change notification settings - Fork 9
116 lines (106 loc) · 4.2 KB
/
manual-vscode-boxel-tools.yml
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
name: Manual Deploy [vscode-boxel-tools]
on:
workflow_dispatch:
inputs:
environment:
description: Deployment environment
required: false
default: staging
workflow_call:
inputs:
environment:
required: true
type: string
jobs:
check-version:
name: Check for changes since last version update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # 4.3.0
with:
node-version: "20"
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Check for version change and subsequent modifications
id: check
run: |
PACKAGE_JSON="packages/vscode-boxel-tools/package.json"
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./$PACKAGE_JSON').version")
echo "Current version in package.json: $CURRENT_VERSION"
# Get latest version from VS Code Marketplace
MARKETPLACE_DATA=$(vsce show cardstack.boxel-tools --json)
MARKETPLACE_VERSION=$(echo "$MARKETPLACE_DATA" | jq -r '.versions[0].version')
echo "Marketplace version: $MARKETPLACE_VERSION"
if [ "$CURRENT_VERSION" = "$MARKETPLACE_VERSION" ]; then
echo "Error: The version in package.json ($CURRENT_VERSION) is the same as the Marketplace version. Please update the version before publishing."
exit 1
else
echo "Extension version has changed. Proceeding with check for relevant changes since then."
echo ""
fi
# Find the most recent commit that changed the version in package.json
LAST_VERSION_CHANGE=$(git rev-list -n 1 HEAD -- $PACKAGE_JSON | while read commit; do
if git show $commit:$PACKAGE_JSON | grep -q "\"version\": \"$CURRENT_VERSION\""; then
echo $commit
break
fi
done)
echo "Last version change commit: $LAST_VERSION_CHANGE"
if [ -z "$LAST_VERSION_CHANGE" ]; then
echo "Error: No version change found in git history. Will not publish."
exit 1
else
echo "Checking for changes since version was updated in $LAST_VERSION_CHANGE"
CHANGES=$(git diff --name-only $LAST_VERSION_CHANGE HEAD -- packages/vscode-boxel-tools packages/runtime-common/realm-auth-client.ts)
echo "Changes detected:"
echo "$CHANGES"
if [ -z "$CHANGES" ]; then
echo ""
echo "No changes detected since last version update. Proceeding with publish."
exit 0
else
git status
git diff
echo ""
echo "Error: Changes have been detected since the extension version was updated. Will not publish."
exit 1
fi
fi
publish:
name: Package and publish VS Code Boxel Tools extension
needs: check-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- uses: ./.github/actions/init
- name: Build boxel-ui
run: pnpm build
working-directory: packages/boxel-ui/addon
- name: Package
run: pnpm vscode:package
working-directory: packages/vscode-boxel-tools
- name: Publish to Visual Studio Marketplace
run: |
if [ "${{ inputs.environment }}" = "production" ]; then
pnpm vscode:publish
else
pnpm vscode:publish:prerelease
fi
working-directory: packages/vscode-boxel-tools
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Publish to Open VSX
run: |
if [ "${{ inputs.environment }}" = "production" ]; then
npx ovsx publish --no-dependencies --pat $OVSX_TOKEN
else
npx ovsx publish --no-dependencies --pre-release --pat $OVSX_TOKEN
fi
working-directory: packages/vscode-boxel-tools
env:
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}