Skip to content

Commit 2e09ec4

Browse files
npm registry
ISSUE: CLDSRVCLT-7
1 parent adc3ab3 commit 2e09ec4

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ run-name: release ${{ inputs.tag }}
44

55
on:
66
# Uncomment to test your work as a release before it's merged
7-
# push:
8-
# branches:
9-
# - improvement/CLDSRVCLT-X
7+
push:
8+
branches:
9+
- improvement/CLDSRVCLT-7
1010
workflow_dispatch:
1111
inputs:
1212
tag:
1313
description: 'Tag to be released (e.g., 1.0.0)'
1414
required: true
1515

1616
jobs:
17-
build-and-tag:
18-
name: Build and tag
17+
build-and-publish:
18+
name: Build and publish to GitHub Packages
1919
runs-on: ubuntu-latest
2020
permissions:
2121
contents: write
22+
packages: write
2223

2324
steps:
2425
- name: Checkout code
@@ -27,40 +28,46 @@ jobs:
2728
- name: Setup and Build
2829
uses: ./.github/actions/setup-and-build
2930

30-
- name: Create Tag with Build Artifacts
31+
- name: Update package version
3132
run: |
32-
# Configure git user to the GitHub Actions bot
33-
git config --global user.name "github-actions[bot]"
34-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
35-
36-
# Force add the build folders (even if they are in .gitignore)
37-
git add -f dist build
38-
39-
# Determine tag name
40-
TAG_NAME="${{ inputs.tag }}"
41-
if [ -z "$TAG_NAME" ]; then
42-
TAG_NAME="test-${{ github.sha }}"
43-
fi
44-
45-
# Commit the build artifacts
46-
git commit -m "Build artifacts for version $TAG_NAME"
33+
# Update version in package.json
34+
npm version ${{ inputs.tag }} --no-git-tag-version
35+
36+
- name: Configure package for GitHub Packages
37+
run: |
38+
# Add publishConfig to package.json for GitHub Packages
39+
node -e "
40+
const pkg = require('./package.json');
41+
pkg.publishConfig = {
42+
registry: 'https://npm.pkg.github.com'
43+
};
44+
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
45+
"
4746
48-
# Create the tag
49-
git tag $TAG_NAME
47+
- name: Setup .npmrc for authentication
48+
run: |
49+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc
50+
echo "@${{ github.repository_owner }}:registry=https://npm.pkg.github.com" >> .npmrc
5051
51-
# Push the tag to the repository
52-
git push origin $TAG_NAME
52+
- name: Publish to GitHub Packages
53+
run: npm publish
54+
env:
55+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5356

54-
# Export tag name for next step
55-
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
56-
id: create_tag
57+
- name: Create Git Tag
58+
run: |
59+
git config --global user.name "github-actions[bot]"
60+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
61+
git tag ${{ inputs.tag }}
62+
git push origin ${{ inputs.tag }}
5763
5864
- name: Create GitHub Release
5965
uses: softprops/action-gh-release@v2
6066
with:
61-
tag_name: ${{ steps.create_tag.outputs.tag_name }}
62-
name: Release ${{ steps.create_tag.outputs.tag_name }}
67+
tag_name: ${{ inputs.tag }}
68+
name: Release ${{ inputs.tag }}
6369
draft: false
6470
prerelease: false
71+
generate_release_notes: true
6572
env:
6673
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)