|
1 | | -name: Node.js Package |
| 1 | +name: Javascript Wrapper Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - "*" |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + cliTag: |
| 7 | + description: 'CLI tag name' |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + default: 2.0.0-nightly |
| 11 | + jsTag: |
| 12 | + description: 'JS Wrapper tag name' |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + default: nightly |
| 16 | + dev: |
| 17 | + description: 'Is dev build' |
| 18 | + required: false |
| 19 | + default: true |
| 20 | + type: boolean |
| 21 | + workflow_dispatch: |
| 22 | + inputs: |
| 23 | + cliTag: |
| 24 | + description: 'CLI tag name (ignored if not dev build)' |
| 25 | + required: false |
| 26 | + jsTag: |
| 27 | + description: 'Tag name (ignored if not dev build)' |
| 28 | + required: false |
| 29 | + type: string |
| 30 | + default: rc |
| 31 | + dev: |
| 32 | + description: 'Is dev build' |
| 33 | + required: false |
| 34 | + default: true |
| 35 | + type: boolean |
| 36 | + |
| 37 | +permissions: |
| 38 | + id-token: write |
| 39 | + contents: write |
| 40 | + packages: write |
7 | 41 |
|
8 | 42 | jobs: |
| 43 | + delete: |
| 44 | + uses: CheckmarxDev/ast-cli-javascript-wrapper/.github/workflows/delete-packages-and-releases.yml@main |
| 45 | + with: |
| 46 | + tag: ${{ inputs.jsTag }} |
| 47 | + secrets: inherit |
| 48 | + if: inputs.dev == true |
9 | 49 | release: |
10 | 50 | runs-on: ubuntu-latest |
11 | 51 | steps: |
| 52 | + |
| 53 | + # CHECKOUT PROJECT |
12 | 54 | - uses: actions/checkout@v3 |
13 | 55 | with: |
14 | 56 | fetch-depth: 0 |
15 | | - - name: Set env |
16 | | - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 57 | + |
| 58 | + # GIT CONFIGURATION |
| 59 | + - run: | |
| 60 | + git config user.name github-actions |
| 61 | + git config user.email github-actions@github.com |
| 62 | +
|
| 63 | + # SETUP NODE |
17 | 64 | - uses: actions/setup-node@v3.6.0 |
18 | 65 | with: |
19 | 66 | node-version: 10 |
20 | 67 | registry-url: https://npm.pkg.github.com/ |
21 | | - - run: npm ci |
22 | | - - name: npm build |
23 | | - run: npm run build |
24 | | - - name: Set up NPM authentication |
25 | | - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc |
26 | | - - run: npm publish --access public |
27 | | - env: |
28 | | - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
29 | | - - name: Changelog |
30 | | - uses: Bullrich/generate-release-changelog@master |
31 | | - id: Changelog |
| 68 | + |
| 69 | + # GET TAG NAME |
| 70 | + - name: Generate Tag name |
| 71 | + run: | |
| 72 | + if [ ${{ inputs.dev }} == true ]; then |
| 73 | + echo "TAG_NAME=$(npm version prerelease --preid=${{ inputs.jsTag }} --no-git-tag-version --allow-same-version)" >> $GITHUB_ENV |
| 74 | + else |
| 75 | + echo "TAG_NAME=$(npm version patch)" >> $GITHUB_ENV |
| 76 | + fi |
| 77 | +
|
| 78 | + # DOWNLOAD CLI IF IT IS A DEV VERSION AND A CLI TAG WAS PROVIDED |
| 79 | + - name: Download cli with tag ${{ inputs.cliTag }} |
| 80 | + if: inputs.dev == true && inputs.cliTag != '' |
| 81 | + run: | |
| 82 | + # Update binaries |
| 83 | + chmod +x ./.github/scripts/update_cli.sh |
| 84 | + ./.github/scripts/update_cli.sh ${{ inputs.cliTag }} |
| 85 | +
|
| 86 | + # RUN NPM INSTALL AND BUILD |
| 87 | + - name: NPM ci and build |
| 88 | + run: | |
| 89 | + npm ci |
| 90 | + npm run build |
| 91 | +
|
| 92 | + # PUSH TAGS IF IT IS A RELEASE |
| 93 | + - name: Push tag if release |
| 94 | + if: inputs.dev == false |
| 95 | + run: git push && git push --tags |
| 96 | + |
| 97 | + # PUBLISH NPM PACKAGE |
| 98 | + - name: Publish npm package |
| 99 | + run: | |
| 100 | + if [ ${{ inputs.dev }} == true ]; then |
| 101 | + npm publish --tag=${{ inputs.jsTag }} |
| 102 | + else |
| 103 | + npm publish --access public |
| 104 | + fi |
32 | 105 | env: |
33 | | - REPO: ${{ github.repository }} |
| 106 | + NODE_AUTH_TOKEN: ${{secrets.PERSONAL_ACCESS_TOKEN}} |
| 107 | + |
| 108 | + # CREATE RELEASE |
34 | 109 | - name: Create Release |
35 | 110 | id: create_release |
36 | 111 | uses: actions/create-release@v1 |
37 | 112 | env: |
38 | 113 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
39 | 114 | with: |
40 | | - tag_name: ${{ github.ref }} |
41 | | - release_name: Release ${{ github.ref }} |
42 | | - body: | |
43 | | - ${{ steps.Changelog.outputs.changelog }} |
| 115 | + tag_name: ${{env.TAG_NAME}} |
| 116 | + release_name: Release ${{env.TAG_NAME}} |
| 117 | + body: ${{ steps.Changelog.outputs.changelog }} |
44 | 118 | draft: false |
45 | | - prerelease: false |
| 119 | + prerelease: ${{ inputs.dev }} |
0 commit comments