|
1 | 1 | name: Build and Release |
| 2 | + |
2 | 3 | on: |
3 | | - push: |
4 | | - branches: |
5 | | - - main |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + npm-version-arg: |
| 7 | + description: Argument to npm-version |
| 8 | + default: minor |
| 9 | + required: true |
6 | 10 |
|
7 | 11 | jobs: |
8 | 12 | build: |
9 | 13 | name: Build |
10 | 14 | runs-on: ubuntu-latest |
11 | 15 | outputs: |
12 | | - tag: ${{ steps.release_info.outputs.tag }} |
| 16 | + tag: ${{ steps.release_info.outputs.tag }} |
13 | 17 | steps: |
14 | 18 | - uses: actions/checkout@v2 |
15 | 19 | with: |
16 | 20 | token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + - name: Configure git |
| 23 | + run: | |
| 24 | + git config user.name 'Release Action' |
| 25 | + git config user.email '<>' |
| 26 | +
|
17 | 27 | - uses: actions/setup-node@v1 |
18 | 28 | with: |
19 | | - node-version: '12' |
20 | | - - name: Perform npm tasks |
21 | | - run: npm run ci |
| 29 | + node-version: "12" |
22 | 30 |
|
23 | | - - name: Set release vars |
24 | | - id: release_helpers |
| 31 | + - name: Update package version |
| 32 | + id: update-package-version |
25 | 33 | run: | |
26 | | - echo "::set-output name=commit::$(git rev-parse --short HEAD)" |
27 | | - echo "::set-output name=package_version::$(node -e "console.log(require('./package.json').version);")" |
| 34 | + VERSION=$(npm version "${{ github.event.inputs.npm-version-arg }}") |
| 35 | + echo "::set-output name=version::$VERSION" |
| 36 | +
|
| 37 | + - name: Push new version |
| 38 | + run: git push |
| 39 | + |
| 40 | + - name: Perform npm tasks |
| 41 | + run: npm run ci |
28 | 42 |
|
29 | 43 | - name: Commit to release branch |
30 | 44 | id: release_info |
31 | 45 | run: | |
32 | | - git config user.name 'Build Action' |
33 | | - git config user.email '<>' |
34 | | -
|
35 | | - TAG="v${{ steps.release_helpers.outputs.package_version }}" |
| 46 | + TAG="v${{ steps.update-package-version.outputs.version }}" |
36 | 47 | BRANCH="release/$TAG" |
37 | 48 | git switch -c $BRANCH |
38 | 49 | git add --force dist lib |
39 | 50 |
|
40 | | - MESSAGE="Build for ${{ steps.release_helpers.outputs.commit }}" |
| 51 | + MESSAGE="Build for $(git rev-parse --short HEAD)" |
41 | 52 | git commit --allow-empty -m "$MESSAGE" |
42 | 53 | git tag -a -m "Release $TAG" $TAG |
43 | 54 | git push origin $TAG |
|
0 commit comments