@@ -27,12 +27,59 @@ jobs:
27
27
npm i release-please -g
28
28
- run : |
29
29
release-please release-pr --repo-url $GITHUB_REPOSITORY --token=$RELEASE_TOKEN
30
- - run : |
31
- gh auth status
32
- - run : |
33
- release-please github-release --repo-url $GITHUB_REPOSITORY --token=$RELEASE_TOKEN --dry-run
30
+ - name : Extract Release Information
31
+ shell : pwsh
32
+ id : extract_release_information
33
+ run : |
34
+ $output = release-please release-pr --repo-url $GITHUB_REPOSITORY --token=$env:RELEASE_TOKEN
35
+ # Extract the number of releases
36
+ $releasesMatch = [regex]::Match($output, 'Would tag (\d+) releases:')
37
+ if ($releasesMatch.Success) {
38
+ $numReleases = [int]$releasesMatch.Groups[1].Value
39
+ Write-Host "Number of releases to tag: $numReleases"
40
+
41
+ if ($numReleases -gt 0) {
42
+ # Extract the JSON-like object(s)
43
+ $jsonMatch = [regex]::Match($output, '(?s)\{(.*?)\}', [System.Text.RegularExpressions.RegexOptions]::Singleline)
44
+ if ($jsonMatch.Success) {
45
+ $jsonObject = $jsonMatch.Groups[0].Value
46
+ Write-Host "JSON Object: $jsonObject"
47
+
48
+ # Convert JSON-like object to actual JSON (requires some cleanup)
49
+ $jsonObject = $jsonObject -replace "`n", "" -replace " ", "" -replace "name:", '"name":' -replace "tag:", '"tag":' -replace "notes:", '"notes":' -replace "sha:", '"sha":' -replace "draft:", '"draft":' -replace "prerelease:", '"prerelease":' -replace "pullNumber:", '"pullNumber":'
50
+ # Convert to JSON object
51
+ try {
52
+ $releaseInfo = ConvertFrom-Json $jsonObject
53
+ Write-Host "Release Name: $($releaseInfo.name)"
54
+ Write-Host "Release Tag: $($releaseInfo.tag)"
55
+ Write-Host "Release Notes: $($releaseInfo.notes)"
56
+
57
+ # Set output variables for subsequent steps
58
+ echo "::set-output name=release_name::$($releaseInfo.name)"
59
+ echo "::set-output name=release_tag::$($releaseInfo.tag)"
60
+ echo "::set-output name=release_notes::$($releaseInfo.notes)"
61
+ echo "::set-output name=pullNumber::$($releaseInfo.pullNumber)"
62
+ } catch {
63
+ Write-Error "Failed to convert to JSON: $($_.Exception.Message)"
64
+ exit 1
65
+ }
66
+ } else {
67
+ Write-Warning "No JSON object found in output."
68
+ }
69
+ } else {
70
+ Write-Host "No releases to create."
71
+ }
72
+ } else {
73
+ Write-Warning "Could not determine the number of releases."
74
+ }
34
75
env :
35
76
RELEASE_TOKEN : ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
77
+ - name : Create Release (Dry Run)
78
+ if : steps.extract_release_information.outputs.release_name
79
+ run : |
80
+ echo "Creating release with tag ${{ steps.extract_release_information.outputs.release_tag }}, name ${{ steps.extract_release_information.outputs.release_name }}, notes ${{ steps.extract_release_information.outputs.release_notes }}"
81
+ gh release create ${{ steps.extract_release_information.outputs.release_tag }} --notes=${{ steps.extract_release_information.outputs.release_notes }} --title ${{ steps.extract_release_information.outputs.release_name }} --repo $GITHUB_REPOSITORY --prerelease
82
+ gh pr edit ${{ steps.extract_release_information.outputs.pullName }} --repo $GITHUB_REPOSITORY --add-label "autorelease: tagged" --remove-label "autorelease: pending"
36
83
37
84
38
85
0 commit comments