Repository navigation
91 lines (81 loc) · 3.16 KB
/
Copy pathrelease.yml
File metadata and controls
91 lines (81 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Prepare Release
on:
workflow_dispatch:
inputs:
channel:
description: 'beta = x.y.z-beta.n を出す / stable = 開いているプレリリース列を正式版へ昇格する'
required: true
default: beta
type: choice
options: [beta, stable]
version:
description: '算出結果を使わずバージョンを指定する場合のみ入力(例: 2.0.0)'
required: false
type: string
permissions:
contents: read
jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/create-github-app-token@v3
id: app-token
with:
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- uses: actions/checkout@v7
with:
ref: develop
token: ${{ steps.app-token.outputs.token }}
- uses: dart-lang/setup-dart@v1
# バージョンは CHANGELOG の [Unreleased] から導く。コミットメッセージから
# 推測しないのは、このプロジェクトの履歴で破壊的変更が docs: として記録
# されていた実績があるため。
- name: Resolve the version
id: resolve
env:
CHANNEL: ${{ inputs.channel }}
OVERRIDE: ${{ inputs.version }}
run: |
set -euo pipefail
if [ -n "$OVERRIDE" ]; then
version="$OVERRIDE"
echo "Using the version given by the operator: $version"
else
dart run tool/next_version.dart "$CHANNEL" "$RUNNER_TEMP/version.txt"
version="$(cat "$RUNNER_TEMP/version.txt")"
echo "Derived from CHANGELOG.md: $version"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Bump version
env:
TZ: Asia/Tokyo
VERSION: ${{ steps.resolve.outputs.version }}
run: dart run tool/bump_version.dart "$VERSION"
- name: Create release branch
env:
VERSION: ${{ steps.resolve.outputs.version }}
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git switch -c "release/$VERSION"
git commit -am "chore(release): $VERSION"
git push -u origin "release/$VERSION"
- name: Open pull request
env:
CHANNEL: ${{ inputs.channel }}
OVERRIDE: ${{ inputs.version }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
VERSION: ${{ steps.resolve.outputs.version }}
run: |
if [ -n "$OVERRIDE" ]; then
ORIGIN="実行者が指定したバージョンです。"
else
ORIGIN="\`CHANGELOG.md\` の \`[Unreleased]\` から算出したバージョンです(チャンネル: \`$CHANNEL\`)。"
fi
gh pr create \
--base main \
--head "release/$VERSION" \
--title "release: $VERSION" \
--body "$ORIGIN マージすると \`v$VERSION\` タグが作成され、pub.dev への公開と GitHub Release の作成まで自動で進みます。"