-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (98 loc) · 3.47 KB
/
publish.yml
File metadata and controls
114 lines (98 loc) · 3.47 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
name: Publish to npm
on:
workflow_dispatch:
inputs:
version_type:
description: "Version increment type"
required: true
type: choice
options:
- patch
- minor
- major
default: patch
permissions:
contents: write
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
environment: npm-publish
concurrency:
group: publish-npm
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: npm
- name: Get current npm version
id: current_version
run: |
CURRENT_VERSION=$(npm view @github/copilot-engine-sdk version 2>/dev/null || echo "0.0.0")
echo "version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "Current published version: $CURRENT_VERSION"
echo "- Current published version: \`$CURRENT_VERSION\`" >> "$GITHUB_STEP_SUMMARY"
- name: Calculate next version
id: next_version
run: |
CURRENT="${{ steps.current_version.outputs.version }}"
NEXT_VERSION=$(npx --yes semver "$CURRENT" -i "$VERSION_TYPE")
if [ -z "$NEXT_VERSION" ]; then
echo "Failed to calculate next version from $CURRENT using increment $VERSION_TYPE" >&2
exit 1
fi
echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
echo "Next version: $NEXT_VERSION (incremented $VERSION_TYPE from $CURRENT)"
echo "- Next version: \`$NEXT_VERSION\` (incremented $VERSION_TYPE from \`$CURRENT\`)" >> "$GITHUB_STEP_SUMMARY"
env:
VERSION_TYPE: ${{ inputs.version_type }}
- name: Set package version
env:
VERSION: ${{ steps.next_version.outputs.version }}
run: npm version "$VERSION" --no-git-tag-version
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Create npm tarball
run: npm pack
- name: Publish to npm
run: npm publish --access public
- name: Determine previous release tag
id: previous_tag
run: |
PREVIOUS_TAG=$(gh release list --limit 1 --exclude-drafts --exclude-pre-releases --json tagName --jq '.[0].tagName // empty' 2>/dev/null || echo "")
echo "tag=$PREVIOUS_TAG" >> "$GITHUB_OUTPUT"
if [ -n "$PREVIOUS_TAG" ]; then
echo "Previous release tag: $PREVIOUS_TAG"
echo "- Previous release tag: \`$PREVIOUS_TAG\`" >> "$GITHUB_STEP_SUMMARY"
else
echo "No previous release found"
echo "- No previous release found" >> "$GITHUB_STEP_SUMMARY"
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Create GitHub release
env:
VERSION: ${{ steps.next_version.outputs.version }}
PREVIOUS_TAG: ${{ steps.previous_tag.outputs.tag }}
GH_TOKEN: ${{ github.token }}
run: |
TAG="v${VERSION}"
RELEASE_ARGS=(
"$TAG"
--title "$TAG"
--generate-notes
./*.tgz
)
if [ -n "$PREVIOUS_TAG" ]; then
RELEASE_ARGS+=(--notes-start-tag "$PREVIOUS_TAG")
fi
gh release create "${RELEASE_ARGS[@]}" >> "$GITHUB_STEP_SUMMARY" 2>&1