Skip to content

Commit daf8c24

Browse files
ci: add release CI (#4)
1 parent adccc7c commit daf8c24

File tree

5 files changed

+172
-4
lines changed

5 files changed

+172
-4
lines changed

.github/workflows/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
target-branch: "main"
8+
commit-message:
9+
prefix: "fix:"
10+
11+
- package-ecosystem: "github-actions"
12+
directory: "/"
13+
schedule:
14+
interval: "monthly"
15+
target-branch: "main"
16+
commit-message:
17+
prefix: "ci:"

.github/workflows/release.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Release New Version
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: "The version to release"
7+
required: false
8+
default: ""
9+
10+
concurrency:
11+
group: release-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
SVU_VERSION: "3.3.3"
16+
17+
permissions:
18+
contents: write
19+
id-token: write
20+
21+
jobs:
22+
build-with-latest-hapi-release:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Import Vault Credentials
26+
id: import-secrets
27+
uses: spectrocloud/palette-sdk-typescript/.github/actions/vault-credentials@main
28+
29+
- name: Checkout
30+
uses: actions/[email protected]
31+
with:
32+
token: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}
33+
34+
- name: Setup Node.js environment
35+
uses: actions/[email protected]
36+
with:
37+
node-version: "22"
38+
cache: "npm"
39+
registry-url: "https://npm.pkg.github.com"
40+
41+
- name: Setup Copywrite
42+
uses: hashicorp/[email protected]
43+
44+
- name: Checkout HAPI Repository
45+
uses: actions/[email protected]
46+
with:
47+
repository: spectrocloud/hapi
48+
path: api/hapi
49+
fetch-depth: "0"
50+
token: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}
51+
52+
- name: Install dependencies
53+
run: make install-dependencies
54+
55+
- name: Install Go Swagger
56+
run: |
57+
dir=$(mktemp -d)
58+
download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
59+
jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url')
60+
curl -o $dir/swagger -L'#' "$download_url"
61+
sudo install $dir/swagger /usr/local/bin
62+
63+
- name: Ensure Reviewable
64+
run: make check-diff
65+
66+
- name: Generate
67+
run: make generate
68+
69+
- name: Test
70+
env:
71+
# Expires 2026-12-31. Tenant is https://palette-ai-rsch.console.spectrocloud.com/
72+
PALETTE_API_KEY: ${{ secrets.PALETTE_API_KEY }}
73+
run: make test
74+
75+
- name: Get svu
76+
run: |
77+
URL="https://github.com/caarlos0/svu/releases/download/v${SVU_VERSION}/svu_${SVU_VERSION}_linux_amd64.tar.gz"
78+
wget --quiet $URL --output-document svu.tar.gz
79+
tar -xzf svu.tar.gz
80+
chmod +x svu
81+
sudo mv svu /usr/local/bin/
82+
svu --version
83+
84+
- id: tag
85+
run: |
86+
INPUT_VERSION="${{ github.event.inputs.version }}"
87+
88+
if [ -n "$INPUT_VERSION" ]; then
89+
echo "Using provided version: $INPUT_VERSION"
90+
VERSION="$INPUT_VERSION"
91+
PREV_VERSION=$(svu current --tag.mode all)
92+
echo "SAME_VERSION=false" >> $GITHUB_OUTPUT
93+
94+
# Check if the tag already exists before creating it
95+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
96+
echo "Tag $VERSION already exists, skipping tag creation."
97+
else
98+
git tag "$VERSION"
99+
git push --tags
100+
fi
101+
else
102+
VERSION=$(svu next --tag.mode all)
103+
PREV_VERSION=$(svu current --tag.mode all)
104+
105+
if [ "$VERSION" = "$PREV_VERSION" ]; then
106+
echo "no new version detected"
107+
SAME_VERSION=true
108+
echo "SAME_VERSION=true" >> $GITHUB_OUTPUT
109+
else
110+
echo "new version detected"
111+
SAME_VERSION=false
112+
echo "SAME_VERSION=false" >> $GITHUB_OUTPUT
113+
114+
# Check if the tag already exists before creating it
115+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
116+
echo "Tag $VERSION already exists, skipping tag creation."
117+
else
118+
git tag "$VERSION"
119+
git push --tags
120+
fi
121+
fi
122+
fi
123+
124+
# Strip v prefix for npm version
125+
NPM_VERSION="${VERSION#v}"
126+
127+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
128+
echo "NPM_VERSION=$NPM_VERSION" >> $GITHUB_OUTPUT
129+
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_OUTPUT
130+
131+
- name: Set package version
132+
if: steps.tag.outputs.SAME_VERSION != 'true'
133+
run: npm version ${{ steps.tag.outputs.NPM_VERSION }} --no-git-tag-version
134+
135+
- name: Publish to npm
136+
if: steps.tag.outputs.SAME_VERSION != 'true'
137+
run: npm publish
138+
env:
139+
NODE_AUTH_TOKEN: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}
140+
141+
- name: Commit reviewable diff
142+
if: steps.tag.outputs.SAME_VERSION != 'true'
143+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
144+
with:
145+
commit_message: "chore: release ${{ steps.tag.outputs.VERSION }}"

.npmrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
registry=https://registry.npmjs.org/
2-
access=public
2+
@spectrocloud:registry=https://npm.pkg.github.com
3+
access=public
4+
ignore-scripts=true

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
2-
"name": "palette-sdk-typescript",
2+
"name": "@spectrocloud/palette-sdk-typescript",
33
"version": "0.0.5",
44
"description": "TypeScript SDK for Spectro Cloud Palette API",
55
"main": "dist/palette/index.js",
66
"types": "dist/palette/index.d.ts",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/spectrocloud/palette-sdk-typescript"
10+
},
711
"exports": {
812
".": {
913
"import": "./dist/palette/index.js",

0 commit comments

Comments
 (0)