|
3 | 3 | push: |
4 | 4 | branches: |
5 | 5 | - master |
6 | | -jobs: |
7 | 6 |
|
| 7 | +jobs: |
8 | 8 | build: |
9 | | - name: build-package |
10 | | - runs-on: ubuntu-latest |
11 | | - steps: |
| 9 | + name: build-and-publish |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
12 | 12 | - name: Checkout repository |
13 | | - uses: actions/checkout@v3 |
14 | | - - name: Setup node |
15 | | - uses: actions/setup-node@v1 |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Setup Node.js |
| 16 | + uses: actions/setup-node@v3 |
16 | 17 | with: |
17 | | - node-version: '18.13.0' |
18 | | - - name: Restore npm packages |
| 18 | + node-version: 18 |
| 19 | + registry-url: "https://registry.npmjs.org" |
| 20 | + |
| 21 | + - name: Install dependencies |
19 | 22 | run: npm ci |
20 | | - - name: Install Angular |
| 23 | + |
| 24 | + - name: Install Angular CLI |
21 | 25 | run: npm install -g @angular/cli |
| 26 | + |
22 | 27 | - name: Build package |
23 | 28 | run: npm run build:lib |
24 | | - - name: Publish if version has been updated |
25 | | - if: github.ref == 'refs/heads/master' |
26 | | - uses: pascalgn/npm-publish-action@1.3.9 |
27 | | - with: |
28 | | - tag_name: "v%s" |
29 | | - tag_message: "v%s" |
30 | | - create_tag: "true" |
31 | | - commit_pattern: "^chore\\(release\\): (\\S+)" |
32 | | - workspace: "./@packaged/angular-star-rating" |
33 | | - publish_command: "yarn" |
34 | | - publish_args: "--non-interactive" |
35 | | - env: |
36 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | | - NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
38 | 29 |
|
| 30 | + - name: Publish to npm (only on chore(release): x.x.x commits) |
| 31 | + if: startsWith(github.event.head_commit.message, 'chore(release):') |
| 32 | + working-directory: ./@packaged/angular-star-rating |
| 33 | + run: | |
| 34 | + VERSION=$(node -p "require('./package.json').version") |
| 35 | + echo "Publishing version $VERSION" |
| 36 | +
|
| 37 | + # publish to npm |
| 38 | + npm publish --access public |
| 39 | +
|
| 40 | + # configure git |
| 41 | + git config user.name "${{ github.actor }}" |
| 42 | + git config user.email "${{ github.actor }}@users.noreply.github.com" |
| 43 | +
|
| 44 | + # create + push tag |
| 45 | + git tag "v$VERSION" |
| 46 | + git push origin "v$VERSION" |
| 47 | + env: |
| 48 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments