Skip to content

Commit 1d67013

Browse files
committed
chore(ci): test release
1 parent e081b5e commit 1d67013

File tree

2 files changed

+56
-104
lines changed

2 files changed

+56
-104
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 56 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,87 @@
11
name: Create new Release
2-
32
on:
43
push:
54
branches: [main]
6-
pull_request:
7-
branches: [main]
5+
workflow_dispatch:
86

97
jobs:
108
release:
119
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
id-token: write
13+
outputs:
14+
exists: ${{ steps.tag-check.outputs.exists }}
15+
version: ${{ steps.pkg.outputs.version }}
1216

1317
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
1619
with:
1720
fetch-depth: 0
1821

19-
- name: Setup Node.js
20-
uses: actions/setup-node@v4
22+
- uses: actions/setup-node@v4
2123
with:
2224
node-version: "18"
2325
cache: "npm"
26+
registry-url: "https://registry.npmjs.org"
2427

25-
- name: Install dependencies
26-
run: npm ci
27-
28-
- name: Run type check
29-
run: npm run check
28+
- run: npm ci
29+
- run: npm run check
30+
- run: npm run build
3031

31-
- name: Build package
32-
run: npm run build
32+
- name: Get version from package.json
33+
id: pkg
34+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
3335

34-
- name: Check for version bump
35-
id: version-check
36+
- name: Check if tag exists
37+
id: tag-check
3638
run: |
37-
CURRENT_VERSION=$(node -p "require('./package.json').version")
38-
39-
# Try to get npm version, if package doesn't exist, treat as 0.0.0
40-
if NPM_VERSION=$(npm view judgeval version 2>/dev/null); then
41-
echo "npm_version=$NPM_VERSION" >> $GITHUB_OUTPUT
42-
echo "Found published version: $NPM_VERSION"
39+
if git rev-parse "v${{ steps.pkg.outputs.version }}" >/dev/null 2>&1; then
40+
echo "exists=true" >> $GITHUB_OUTPUT
4341
else
44-
NPM_VERSION="0.0.0"
45-
echo "npm_version=$NPM_VERSION" >> $GITHUB_OUTPUT
46-
echo "Package not found on npm, treating as 0.0.0"
42+
echo "exists=false" >> $GITHUB_OUTPUT
4743
fi
4844
49-
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
45+
- name: Create and push tag
46+
if: steps.tag-check.outputs.exists == 'false'
47+
run: |
48+
git config user.name "github-actions"
49+
git config user.email "github-actions@github.com"
50+
git tag v${{ steps.pkg.outputs.version }}
51+
git push origin v${{ steps.pkg.outputs.version }}
5052
51-
if [ "$CURRENT_VERSION" != "$NPM_VERSION" ]; then
52-
echo "version_changed=true" >> $GITHUB_OUTPUT
53-
echo "Version bumped from $NPM_VERSION to $CURRENT_VERSION"
54-
else
55-
echo "version_changed=false" >> $GITHUB_OUTPUT
56-
echo "Version $CURRENT_VERSION already published to npm"
57-
exit 1
58-
fi
53+
publish:
54+
needs: release
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
id-token: write
5959

60-
- name: Create Release
61-
if: steps.version-check.outputs.version_changed == 'true'
62-
id: create_release
63-
uses: actions/create-release@v1
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
with:
67-
tag_name: v${{ steps.version-check.outputs.current_version }}
68-
release_name: Release v${{ steps.version-check.outputs.current_version }}
69-
body: |
70-
## Release v${{ steps.version-check.outputs.current_version }}
60+
if: needs.release.outputs.exists == 'false'
7161

72-
**Diff since previous release:**
73-
[View changes](https://github.com/${{ github.repository }}/compare/v${{ steps.version-check.outputs.npm_version }}...v${{ steps.version-check.outputs.current_version }})
62+
steps:
63+
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
7466

75-
**Version changes:**
76-
- Previous: ${{ steps.version-check.outputs.npm_version }}
77-
- Current: ${{ steps.version-check.outputs.current_version }}
78-
draft: false
79-
prerelease: false
67+
- uses: actions/setup-node@v4
68+
with:
69+
node-version: "18"
70+
registry-url: "https://registry.npmjs.org"
71+
cache: "npm"
8072

81-
- name: Create release package
82-
if: steps.version-check.outputs.version_changed == 'true'
83-
run: zip -r judgeval-v${{ steps.version-check.outputs.current_version }}.zip dist/
73+
- run: npm ci
74+
- run: npm run check
75+
- run: npm run build
8476

85-
- name: Upload Release Assets
86-
if: steps.version-check.outputs.version_changed == 'true'
87-
uses: actions/upload-release-asset@v1
77+
- name: Publish to npm
78+
run: npm publish
8879
env:
89-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
81+
82+
- name: Create GitHub Release
83+
uses: softprops/action-gh-release@v1
9084
with:
91-
upload_url: ${{ steps.create_release.outputs.upload_url }}
92-
asset_path: ./judgeval-v${{ steps.version-check.outputs.current_version }}.zip
93-
asset_name: judgeval-v${{ steps.version-check.outputs.current_version }}.zip
94-
asset_content_type: application/zip
85+
tag_name: v${{ needs.release.outputs.version }}
86+
name: Release v${{ needs.release.outputs.version }}
87+
generate_release_notes: true

0 commit comments

Comments
 (0)