|
1 | | -# Copyright 2022 Google LLC |
2 | | -# |
3 | | -# Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | -# you may not use this file except in compliance with the License. |
5 | | -# You may obtain a copy of the License at |
6 | | -# |
7 | | -# http://www.apache.org/licenses/LICENSE-2.0 |
8 | | -# |
9 | | -# Unless required by applicable law or agreed to in writing, software |
10 | | -# distributed under the License is distributed on an "AS IS" BASIS, |
11 | | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | -# See the License for the specific language governing permissions and |
13 | | -# limitations under the License. |
14 | | - |
15 | | -name: 'release' |
| 1 | +name: 'Release' |
16 | 2 |
|
17 | 3 | on: |
18 | 4 | push: |
19 | 5 | branches: |
20 | | - - 'main' |
21 | | - workflow_dispatch: |
| 6 | + - 'main' |
22 | 7 |
|
23 | 8 | jobs: |
24 | | - # build compiles the code and creates a pull request of the compiled result if |
25 | | - # there is a diff. |
26 | | - build: |
27 | | - runs-on: 'ubuntu-latest' |
28 | | - steps: |
29 | | - - uses: 'actions/checkout@v3' |
30 | | - |
31 | | - - uses: 'actions/setup-node@v3' |
32 | | - with: |
33 | | - node-version: '16.x' |
34 | | - |
35 | | - - name: 'npm build' |
36 | | - run: 'npm ci && npm run build' |
37 | | - |
38 | | - - name: 'Create pull request' |
39 | | - uses: 'peter-evans/create-pull-request@dcd5fd746d53dd8de555c0f10bca6c35628be47a' |
40 | | - with: |
41 | | - token: '${{ secrets.ACTIONS_BOT_TOKEN }}' |
42 | | - add-paths: 'dist/' |
43 | | - committer: 'google-github-actions-bot <github-actions-bot@google.com>' |
44 | | - author: 'google-github-actions-bot <github-actions-bot@google.com>' |
45 | | - signoff: 'google-github-actions-bot <github-actions-bot@google.com>' |
46 | | - commit-message: 'Build dist' |
47 | | - title: 'chore: build dist' |
48 | | - body: 'Build compiled Typescript' |
49 | | - base: 'main' |
50 | | - branch: 'actions/build' |
51 | | - push-to-fork: 'google-github-actions-bot/ssh-compute' |
52 | | - delete-branch: true |
53 | | - |
54 | | - # create-pull-request creates a release pull request if there are any |
55 | | - # convential commit changes since the last release. |
56 | | - create-pull-request: |
57 | | - runs-on: 'ubuntu-latest' |
58 | | - steps: |
59 | | - - uses: 'google-github-actions/release-please-action@v2' |
60 | | - with: |
61 | | - token: '${{ secrets.ACTIONS_BOT_TOKEN }}' |
62 | | - release-type: 'node' |
63 | | - bump-minor-pre-major: true |
64 | | - command: 'release-pr' |
65 | | - fork: true |
66 | | - |
67 | | - # release does a release on the merge of the release pull request. It also |
68 | | - # updates the floating tag alias for the major version. |
69 | 9 | release: |
70 | | - runs-on: 'ubuntu-latest' |
71 | | - steps: |
72 | | - - id: 'release' |
73 | | - uses: 'google-github-actions/release-please-action@v2' |
74 | | - with: |
75 | | - release-type: 'node' |
76 | | - bump-minor-pre-major: true |
77 | | - command: 'github-release' |
78 | | - |
79 | | - - name: 'Update floating tag' |
80 | | - if: '${{ steps.release.outputs.release_created }}' |
81 | | - uses: 'actions/github-script@v5' |
82 | | - with: |
83 | | - script: |- |
84 | | - const sha = '${{ steps.release.outputs.sha }}' |
85 | | - const major = 'v${{ steps.release.outputs.major }}'; |
86 | | - // Try to update the ref first. If that fails, it probably does not |
87 | | - // exist yet, and we should create it. |
88 | | - try { |
89 | | - await github.rest.git.updateRef({ |
90 | | - owner: context.repo.owner, |
91 | | - repo: context.repo.repo, |
92 | | - ref: `tags/${major}`, |
93 | | - sha: sha, |
94 | | - force: true, |
95 | | - }); |
96 | | - core.info(`Updated ${major} to ${sha}`); |
97 | | - } catch(err) { |
98 | | - core.warning(`Failed to create ${major}: ${err}`); |
99 | | - await github.rest.git.createRef({ |
100 | | - owner: context.repo.owner, |
101 | | - repo: context.repo.repo, |
102 | | - ref: `refs/tags/${major}`, |
103 | | - sha: sha, |
104 | | - }); |
105 | | - core.info(`Created ${major} at ${sha}`); |
106 | | - } |
| 10 | + if: "startsWith(github.event.head_commit.message, 'Release: v')" |
| 11 | + name: 'Release' |
| 12 | + uses: 'google-github-actions/.github/.github/workflows/release.yml@v0' |
0 commit comments