-
Notifications
You must be signed in to change notification settings - Fork 275
76 lines (64 loc) · 2.64 KB
/
release-please-gha.yml
File metadata and controls
76 lines (64 loc) · 2.64 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
## -----------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE.txt in the project root for license information.
## -----------------------------------------------------------------------------
#
# Summary:
# This GitHub Actions workflow automates the release process using Release Please.
# It triggers on pushes to the main branch, generates a GitHub App token using organization
# variables and secrets, and then runs the release-please-action to manage versioning and changelogs.
name: Release Please
on:
push:
branches:
- main
- support/v1
- support/v2
workflow_dispatch:
permissions:
contents: read
jobs:
check-secret:
runs-on: ubuntu-latest
outputs:
has-token: ${{ steps.check.outputs.has-token }}
steps:
- id: check
run: echo "has-token=${{ secrets.RELEASE_PLEASE_TOKEN_PROVIDER_PEM != '' }}" >> $GITHUB_OUTPUT
release:
needs: check-secret
if: needs.check-secret.outputs.has-token == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Validate PublicAPI.Unshipped.txt files are empty
shell: pwsh
run: |
$unshippedFiles = Get-ChildItem 'src/ ' -Recurse -Filter *.Unshipped.txt | Select -ExpandProperty FullName
$hasUnshippedAPIs = $false
foreach ($file in $unshippedFiles) {
$content = Get-Content -Path $file -Raw
# Remove the #nullable enable line and any whitespace
$trimmedContent = $content -replace '^\s*#nullable enable\s*$', '' -replace '^\s+', ''
if ($trimmedContent -ne '') {
Write-Error "❌ $file contains unshipped APIs. Please promote them to PublicAPI.Shipped.txt before releasing.`nContent:`n$content"
$hasUnshippedAPIs = $true
}
}
if ($hasUnshippedAPIs) {
exit 1
}
Write-Output "✅ All PublicAPI.Unshipped.txt files are clean"
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.RELEASE_PLEASE_TOKEN_PROVIDER_APP_ID }}
private-key: ${{ secrets.RELEASE_PLEASE_TOKEN_PROVIDER_PEM }}
- name: Release Please
uses: googleapis/release-please-action@v4
with:
token: ${{ steps.app-token.outputs.token }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
target-branch: ${{ github.ref_name }}