|
1 | 1 | --- |
2 | | -name: release |
3 | | -run-name: release ${{ inputs.tag }} |
| 2 | +name: Release |
| 3 | +run-name: Release |
4 | 4 |
|
5 | 5 | on: |
6 | | - # Uncomment to test your work as a release before it's merged |
7 | | - # push: |
8 | | - # branches: |
9 | | - # - improvement/CLDSRVCLT-X |
| 6 | + # For testing - remove before merging |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - improvement/CLDSRVCLT-7 |
10 | 10 | workflow_dispatch: |
11 | | - inputs: |
12 | | - tag: |
13 | | - description: 'Tag to be released (e.g., 1.0.0)' |
14 | | - required: true |
15 | 11 |
|
16 | 12 | jobs: |
17 | | - build-and-tag: |
18 | | - name: Build and tag |
| 13 | + build: |
| 14 | + name: Build |
19 | 15 | runs-on: ubuntu-latest |
20 | | - permissions: |
21 | | - contents: write |
22 | | - |
| 16 | + outputs: |
| 17 | + version: ${{ steps.package-version.outputs.version }} |
23 | 18 | steps: |
24 | 19 | - name: Checkout code |
25 | 20 | uses: actions/checkout@v4 |
26 | 21 |
|
| 22 | + - name: Get version from package.json |
| 23 | + id: package-version |
| 24 | + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT |
| 25 | + |
27 | 26 | - name: Setup and Build |
28 | 27 | uses: ./.github/actions/setup-and-build |
29 | 28 |
|
30 | | - - name: Create Tag with Build Artifacts |
31 | | - 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" |
| 29 | + - name: Upload build artifacts |
| 30 | + uses: actions/upload-artifact@v4 |
| 31 | + with: |
| 32 | + name: build-artifacts |
| 33 | + path: | |
| 34 | + dist/ |
| 35 | + build/ |
35 | 36 |
|
36 | | - # Force add the build folders (even if they are in .gitignore) |
37 | | - git add -f dist build |
| 37 | + publish-npm: |
| 38 | + name: Publish to npm registry |
| 39 | + runs-on: ubuntu-latest |
| 40 | + needs: build |
| 41 | + permissions: |
| 42 | + contents: read |
| 43 | + id-token: write |
| 44 | + steps: |
| 45 | + - name: Checkout code |
| 46 | + uses: actions/checkout@v4 |
38 | 47 |
|
39 | | - # Determine tag name |
40 | | - TAG_NAME="${{ inputs.tag }}" |
41 | | - if [ -z "$TAG_NAME" ]; then |
42 | | - TAG_NAME="test-${{ github.sha }}" |
43 | | - fi |
| 48 | + - name: Download build artifacts |
| 49 | + uses: actions/download-artifact@v4 |
| 50 | + with: |
| 51 | + name: build-artifacts |
44 | 52 |
|
45 | | - # Commit the build artifacts |
46 | | - git commit -m "Build artifacts for version $TAG_NAME" |
| 53 | + - name: Setup Node.js for npm registry |
| 54 | + uses: actions/setup-node@v4 |
| 55 | + with: |
| 56 | + node-version: '24' |
| 57 | + registry-url: 'https://registry.npmjs.org' |
47 | 58 |
|
48 | | - # Create the tag |
49 | | - git tag $TAG_NAME |
| 59 | + - name: Publish to npm with provenance |
| 60 | + run: npm publish --provenance --tag latest |
50 | 61 |
|
51 | | - # Push the tag to the repository |
52 | | - git push origin $TAG_NAME |
| 62 | + create-release: |
| 63 | + name: Create GitHub Release |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: [build, publish-npm] |
| 66 | + permissions: |
| 67 | + contents: write |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
53 | 71 |
|
54 | | - # Export tag name for next step |
55 | | - echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
56 | | - id: create_tag |
| 72 | + - name: Create Git Tag |
| 73 | + run: | |
| 74 | + git config --global user.name "github-actions[bot]" |
| 75 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 76 | + git tag ${{ needs.build.outputs.version }} |
| 77 | + git push origin ${{ needs.build.outputs.version }} |
57 | 78 |
|
58 | 79 | - name: Create GitHub Release |
59 | 80 | uses: softprops/action-gh-release@v2 |
60 | 81 | with: |
61 | | - tag_name: ${{ steps.create_tag.outputs.tag_name }} |
62 | | - name: Release ${{ steps.create_tag.outputs.tag_name }} |
63 | | - draft: false |
64 | | - prerelease: false |
| 82 | + tag_name: ${{ needs.build.outputs.version }} |
| 83 | + name: Release ${{ needs.build.outputs.version }} |
| 84 | + generate_release_notes: true |
65 | 85 | env: |
66 | 86 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments