Update release process (#92)
This commit is contained in:
parent
1b8ec4e237
commit
5975d7549d
94
.github/workflows/release.yml
vendored
Normal file
94
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
name: 'release'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
# build compiles the code and creates a pull request of the compiled result if
|
||||
# there is a diff.
|
||||
build:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v2'
|
||||
|
||||
- uses: 'actions/setup-node@v2'
|
||||
with:
|
||||
node-version: '12.x'
|
||||
|
||||
- name: 'npm build'
|
||||
run: 'npm ci && npm run build'
|
||||
|
||||
- name: 'Create pull request'
|
||||
uses: 'peter-evans/create-pull-request@dcd5fd746d53dd8de555c0f10bca6c35628be47a'
|
||||
with:
|
||||
token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
|
||||
add-paths: 'dist/'
|
||||
committer: 'google-github-actions-bot <github-actions-bot@google.com>'
|
||||
author: 'google-github-actions-bot <github-actions-bot@google.com>'
|
||||
signoff: 'google-github-actions-bot <github-actions-bot@google.com>'
|
||||
commit-message: 'Build dist'
|
||||
title: 'chore: build dist'
|
||||
body: 'Build compiled Typescript'
|
||||
base: 'main'
|
||||
branch: 'actions/build'
|
||||
push-to-fork: 'google-github-actions-bot/auth'
|
||||
delete-branch: true
|
||||
|
||||
# create-pull-request creates a release pull request if there are any
|
||||
# convential commit changes since the last release.
|
||||
create-pull-request:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'google-github-actions/release-please-action@v2'
|
||||
with:
|
||||
token: '${{ secrets.ACTIONS_BOT_TOKEN }}'
|
||||
release-type: 'node'
|
||||
bump-minor-pre-major: true
|
||||
command: 'release-pr'
|
||||
fork: true
|
||||
|
||||
# release does a release on the merge of the release pull request. It also
|
||||
# updates the floating tag alias for the major version.
|
||||
release:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- id: 'release'
|
||||
uses: 'google-github-actions/release-please-action@v2'
|
||||
with:
|
||||
release-type: 'node'
|
||||
bump-minor-pre-major: true
|
||||
command: 'github-release'
|
||||
|
||||
- name: 'Update floating tag'
|
||||
if: '${{ steps.release.outputs.release_created }}'
|
||||
uses: 'actions/github-script@v5'
|
||||
with:
|
||||
script: |-
|
||||
const sha = '${{ steps.release.outputs.sha }}'
|
||||
const major = 'v${{ steps.release.outputs.major }}';
|
||||
|
||||
// Try to update the ref first. If that fails, it probably does not
|
||||
// exist yet, and we should create it.
|
||||
try {
|
||||
await github.rest.git.updateRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `tags/${major}`,
|
||||
sha: sha,
|
||||
force: true,
|
||||
});
|
||||
core.info(`Updated ${major} to ${sha}`);
|
||||
} catch(err) {
|
||||
core.warning(`Failed to create ${major}: ${err}`);
|
||||
|
||||
await github.rest.git.createRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `refs/tags/${major}`,
|
||||
sha: sha,
|
||||
});
|
||||
core.info(`Created ${major} at ${sha}`);
|
||||
}
|
58
.github/workflows/tag.yaml
vendored
58
.github/workflows/tag.yaml
vendored
@ -1,58 +0,0 @@
|
||||
name: 'tag'
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
# match vx.y and v x.y.z.w... but not vx
|
||||
- 'v[0-9]+.*'
|
||||
|
||||
jobs:
|
||||
# pointer parses the incoming tag value and updates the "vX" pointer to the
|
||||
# same SHA as this tag.
|
||||
pointer:
|
||||
name: 'pointer'
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/github-script@v5'
|
||||
with:
|
||||
script: |-
|
||||
const tag = process.env.GITHUB_REF_NAME;
|
||||
if(!tag) {
|
||||
core.setFailed(`Missing tag!`)
|
||||
return
|
||||
}
|
||||
core.info(`Using tag "${tag}"`)
|
||||
|
||||
const matches = tag.match(/(v[0-9]+).*/)
|
||||
if(!matches || matches.length < 2) {
|
||||
core.setFailed(`Invalid tag "${tag}"`)
|
||||
return
|
||||
}
|
||||
const major = matches[1];
|
||||
core.info(`Matched to major tag "${major}"`)
|
||||
|
||||
// Try to update the ref first. If that fails, it probably does not
|
||||
// exist yet, and we should create it.
|
||||
try {
|
||||
await github.rest.git.updateRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `tags/${major}`,
|
||||
sha: context.sha,
|
||||
force: true,
|
||||
})
|
||||
|
||||
core.info(`Updated "${major}" to "${tag}" (${context.sha})`)
|
||||
} catch {
|
||||
core.warning(`Failed to update "${major}" tag (it may not `+
|
||||
`exist). Trying to create "${major}" now.`)
|
||||
|
||||
await github.rest.git.createRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `refs/tags/${major}`,
|
||||
sha: context.sha,
|
||||
})
|
||||
|
||||
core.info(`Created "${major}" at "${tag}" (${context.sha})`)
|
||||
}
|
@ -10,7 +10,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: '${{github.workflow}}-${{ github.head_ref || github.ref }}'
|
||||
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
@ -24,11 +24,8 @@ jobs:
|
||||
with:
|
||||
node-version: '12.x'
|
||||
|
||||
- name: 'npm ci'
|
||||
run: 'npm ci'
|
||||
|
||||
- name: 'npm build'
|
||||
run: 'npm run build'
|
||||
run: 'npm ci && npm run build'
|
||||
|
||||
- name: 'verify compiled'
|
||||
shell: 'bash'
|
Loading…
Reference in New Issue
Block a user