Skip to content

Commit a435375

Browse files
authored
Improve releases flow (#51213)
1 parent e1467ce commit a435375

File tree

2 files changed

+75
-30
lines changed

2 files changed

+75
-30
lines changed

.github/workflows/releases.yml

Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ on:
77
description: 'Version to release'
88
required: true
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
release:
1215
runs-on: ubuntu-latest
1316

17+
name: Release ${{ inputs.version }}
18+
19+
outputs:
20+
version: ${{ steps.version.outputs.version }}
21+
notes: ${{ steps.cleaned-notes.outputs.release-notes }}
22+
1423
steps:
1524
- name: Checkout repository
1625
uses: actions/checkout@v4
@@ -21,6 +30,35 @@ jobs:
2130
VERSION=${{ inputs.version }}
2231
echo "version=${VERSION#v}" >> "$GITHUB_OUTPUT"
2332
33+
- name: Check if branch and version match
34+
id: guard
35+
run: |
36+
MAJOR_VERSION="${NUMERIC_VERSION%%.*}"
37+
BRANCH_MAJOR_VERSION="${BRANCH%%.*}"
38+
39+
echo "MAJOR_VERSION=$(echo $MAJOR_VERSION)" >> $GITHUB_OUTPUT;
40+
echo "BRANCH_MAJOR_VERSION=$(echo $BRANCH_MAJOR_VERSION)" >> $GITHUB_OUTPUT;
41+
42+
if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then
43+
echo "Mismatched versions! Aborting."
44+
VERSION_MISMATCH='true';
45+
else
46+
echo "Versions match! Proceeding."
47+
VERSION_MISMATCH='false';
48+
fi
49+
50+
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> $GITHUB_OUTPUT;
51+
env:
52+
BRANCH: ${{ github.ref_name }}
53+
NUMERIC_VERSION: ${{ steps.version.outputs.version }}
54+
55+
- name: Fail if branch and release tag do not match
56+
if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }}
57+
uses: actions/github-script@v7
58+
with:
59+
script: |
60+
core.setFailed('Workflow failed. Release version does not match with selected target branch. Did you select the correct branch?')
61+
2462
- name: Update Application.php version
2563
run: sed -i "s/const VERSION = '.*';/const VERSION = '${{ steps.version.outputs.version }}';/g" src/Illuminate/Foundation/Application.php
2664

@@ -41,24 +79,40 @@ jobs:
4179
bash ./bin/release.sh v${{ steps.version.outputs.version }}
4280
script_stop: true
4381

44-
# - name: Generate release notes
45-
# id: notes
46-
# uses: RedCrafter07/release-notes-action@main
47-
# with:
48-
# tag-name: v${{ steps.version.outputs.version }}
49-
# token: ${{ secrets.GITHUB_TOKEN }}
50-
# branch: ${{ github.ref_name }}
51-
52-
# - name: Cleanup release notes
53-
# run: |
54-
# sed -i '/## What/d' ${{ steps.notes.outputs.release-notes }}
55-
# sed -i '/## New Contributors/,$d' ${{ steps.notes.outputs.release-notes }}
56-
57-
# - name: Create release
58-
# uses: softprops/action-gh-release@v1
59-
# env:
60-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-
# with:
62-
# tag_name: v${{ steps.version.outputs.version }}
63-
# name: v${{ steps.version.outputs.version }}
64-
# body: ${{ steps.notes.outputs.release-notes }}
82+
- name: Generate release notes
83+
id: generated-notes
84+
uses: RedCrafter07/release-notes-action@main
85+
with:
86+
tag-name: v${{ steps.version.outputs.version }}
87+
token: ${{ secrets.GITHUB_TOKEN }}
88+
branch: ${{ github.ref_name }}
89+
90+
- name: Cleanup release notes
91+
id: cleaned-notes
92+
run: |
93+
NOTES="${{ steps.generated-notes.outputs.release-notes }}"
94+
NOTES=$(echo $NOTES | sed '/## What/d')
95+
NOTES=$(echo $NOTES | sed '/## New Contributors/,$d')
96+
echo "release-notes=${NOTES}" >> "$GITHUB_OUTPUT"
97+
98+
- name: Create release
99+
uses: softprops/action-gh-release@v2
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
with:
103+
tag_name: v${{ steps.version.outputs.version }}
104+
name: v${{ steps.version.outputs.version }}
105+
body: ${{ steps.cleaned-notes.outputs.release-notes }}
106+
target_commitish: ${{ github.ref_name }}
107+
make_latest: 'legacy'
108+
109+
update-changelog:
110+
needs: release
111+
112+
name: Update changelog
113+
114+
uses: laravel/.github/.github/workflows/update-changelog.yml@main
115+
with:
116+
branch: ${{ github.ref_name }}
117+
version: "v${{ needs.release.outputs.version }}"
118+
notes: ${{ needs.release.outputs.notes }}

.github/workflows/update-changelog.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)