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