chore: update release process (#187)
* update release process * Apply suggestions from code review Co-authored-by: Seth Vargo <seth@sethvargo.com> Co-authored-by: Seth Vargo <seth@sethvargo.com>
This commit is contained in:
parent
ceee102ec2
commit
d4641feafe
21
.github/workflows/draft-release.yml
vendored
Normal file
21
.github/workflows/draft-release.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: 'Draft release'
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version_strategy:
|
||||||
|
description: 'Version strategy: The strategy to used to update the version based on semantic versioning (more info at https://semver.org/).'
|
||||||
|
required: true
|
||||||
|
default: 'patch'
|
||||||
|
type: 'choice'
|
||||||
|
options:
|
||||||
|
- 'major'
|
||||||
|
- 'minor'
|
||||||
|
- 'patch'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
draft-release:
|
||||||
|
name: 'Draft release'
|
||||||
|
uses: 'google-github-actions/.github/.github/workflows/draft-release.yml@v0'
|
||||||
|
with:
|
||||||
|
version_strategy: '${{ github.event.inputs.version_strategy }}'
|
92
.github/workflows/release.yml
vendored
92
.github/workflows/release.yml
vendored
@ -1,94 +1,12 @@
|
|||||||
name: 'release'
|
name: 'Release'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
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@v3'
|
|
||||||
|
|
||||||
- uses: 'actions/setup-node@v2'
|
|
||||||
with:
|
|
||||||
node-version: '16.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:
|
release:
|
||||||
runs-on: 'ubuntu-latest'
|
if: "startsWith(github.event.head_commit.message, 'Release: v')"
|
||||||
steps:
|
name: 'Release'
|
||||||
- id: 'release'
|
uses: 'google-github-actions/.github/.github/workflows/release.yml@v0'
|
||||||
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}`);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user