Repository navigation
164 lines (154 loc) · 6.19 KB
/
Copy pathset-version.yaml
File metadata and controls
164 lines (154 loc) · 6.19 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Set branch version
on:
workflow_dispatch:
inputs:
branch_name:
description: Release branch to update
required: true
type: string
package_version:
description: Release package version
required: true
type: string
core_major_minor:
description: Release core major.minor version
required: true
type: string
# Inputs provided by the bot
distinct_id:
description: '(bot) A distinct ID'
required: false
default: ''
source_issue:
description: '(bot) The issue that triggered this workflow'
required: false
default: ''
requesting_user:
description: '(bot) The user who requested this workflow'
required: false
default: ''
status_comment:
description: '(bot) The comment to update with the status of this workflow'
required: false
default: ''
run-name: ${{ github.workflow }}${{ inputs.distinct_id && format(' (bot run {0})', inputs.distinct_id) || '' }}
permissions:
contents: read
id-token: write
defaults:
run:
shell: bash
jobs:
update:
if: github.repository == 'microsoft/TypeScript'
runs-on: ubuntu-latest
environment:
name: azure
deployment: false
steps:
- name: Validate release branch name
env:
BRANCH_NAME: ${{ inputs.branch_name }}
run: |
set -euo pipefail
if ! [[ "$BRANCH_NAME" =~ ^(release-.+|ts[0-9]+-release)$ ]]; then
echo "Release branch name must start with 'release-' or match 'ts<number>-release'." >&2
exit 1
fi
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.branch_name }}
filter: blob:none
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
- uses: ./.github/actions/setup-go
- run: npm ci
- name: Load release automation from main
run: |
set -euo pipefail
git fetch origin main
git show origin/main:tools/scripts/configure-release.mjs > "$RUNNER_TEMP/configure-release.mjs"
- name: Configure release version
id: configure
env:
PACKAGE_VERSION: ${{ inputs.package_version }}
CORE_MAJOR_MINOR: ${{ inputs.core_major_minor }}
run: |
set -euo pipefail
node "$RUNNER_TEMP/configure-release.mjs" "$PACKAGE_VERSION" "$CORE_MAJOR_MINOR"
mapfile -t changedFiles < <(git diff --name-only)
if [ "${#changedFiles[@]}" -eq 0 ]; then
echo "Version is already $PACKAGE_VERSION."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
expectedFiles=("Herebyfile.mjs" "tsc/internal/core/version.go")
for changedFile in "${changedFiles[@]}"; do
if [[ ! " ${expectedFiles[*]} " =~ " $changedFile " ]]; then
echo "Unexpected file in release configuration: $changedFile" >&2
exit 1
fi
done
echo "changed=true" >> "$GITHUB_OUTPUT"
- if: steps.configure.outputs.changed == 'true'
run: npx hereby validate --all
- name: Commit release configuration
if: steps.configure.outputs.changed == 'true'
env:
PACKAGE_VERSION: ${{ inputs.package_version }}
run: |
set -euo pipefail
git diff --check
mapfile -t changedFiles < <(git diff --name-only)
expectedFiles=("Herebyfile.mjs" "tsc/internal/core/version.go")
for changedFile in "${changedFiles[@]}"; do
if [[ ! " ${expectedFiles[*]} " =~ " $changedFile " ]]; then
echo "Validation produced unexpected change: $changedFile" >&2
exit 1
fi
done
git add Herebyfile.mjs tsc/internal/core/version.go
git config user.email "290192711+typescript-automation[bot]@users.noreply.github.com"
git config user.name "typescript-automation[bot]"
git config core.hooksPath /dev/null
git commit -m "Bump version to $PACKAGE_VERSION"
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Create GitHub App token
id: app-token
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
with:
client-id: ${{ vars.TYPESCRIPT_AUTOMATION_GITHUB_APP_CLIENT_ID }}
key-id: ${{ vars.TYPESCRIPT_AUTOMATION_GITHUB_APP_KEY_ID }}
owner: microsoft
repositories: TypeScript
permission-contents: write
- name: Configure git for GitHub App token
if: steps.configure.outputs.changed == 'true'
env:
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -euo pipefail
basic_auth="$(node -e 'process.stdout.write(Buffer.from("x-access-token:" + process.env.GITHUB_APP_TOKEN).toString("base64"))')"
echo "::add-mask::$basic_auth"
git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${basic_auth}"
- if: steps.configure.outputs.changed == 'true'
env:
BRANCH_NAME: ${{ inputs.branch_name }}
run: git push origin "HEAD:$BRANCH_NAME"
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@08bcbbf253fd6bc533dd8b9ab47a58582be57fbe # master
if: ${{ !cancelled() && inputs.distinct_id }}
with:
success_comment: "I've set the version of ${{ inputs.branch_name }} to ${{ inputs.package_version }} for you."
failure_comment: 'I was unable to set the version.'
github_token: ${{ steps.app-token.outputs.token }}
distinct_id: ${{ inputs.distinct_id }}
source_issue: ${{ inputs.source_issue }}
requesting_user: ${{ inputs.requesting_user }}
status_comment: ${{ inputs.status_comment }}