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