Skip to content

Commit 2ea6be3

Browse files
authored
Feature: Automate release flow (#45)
1 parent 14172ce commit 2ea6be3

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed

.craft.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changelogPolicy: auto
2+
preReleaseCommand: pwsh scripts/bump-version.ps1
3+
targets:
4+
- name: github

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- "main"
7+
- "release/**"
78
paths-ignore:
89
- "*.md"
910

@@ -25,3 +26,8 @@ jobs:
2526
name: 🧪 Unit tests
2627
needs: build-extension
2728
uses: ./.github/workflows/unit_tests.yml
29+
30+
package:
31+
name: 📦 Package
32+
needs: build-extension
33+
uses: ./.github/workflows/package.yml

.github/workflows/package.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 📦 Package
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
package:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v4
12+
13+
- name: Download artifact
14+
uses: actions/download-artifact@v4
15+
with:
16+
name: sentry-godot-gdextension
17+
path: artifact/
18+
19+
- name: Prepare artifact
20+
shell: bash
21+
run: |
22+
# * Fix crashpad_handler permissions, workaround for https://github.com/actions/upload-artifact/issues/38
23+
chmod +x artifact/addons/sentrysdk/bin/{linux,macos}/crashpad_handler
24+
# * Create release archive
25+
version=$(grep 'VERSION =' SConstruct | cut -d '"' -f 2)
26+
git_short_sha=$(git rev-parse --short HEAD)
27+
archive_file="sentry-godot-gdextension-${version}+${git_short_sha}.zip"
28+
cd artifact/
29+
mkdir ${GITHUB_WORKSPACE}/out/
30+
zip -r ${GITHUB_WORKSPACE}/out/${archive_file} ./*
31+
32+
- name: Upload artifact
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: ${{github.sha}}
36+
path: out/*

.github/workflows/release.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 🎁 Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Version to release
8+
required: true
9+
force:
10+
description: Force a release even when there are release-blockers (optional)
11+
required: false
12+
13+
jobs:
14+
job_release:
15+
runs-on: ubuntu-latest
16+
name: 'Release a new version: ${{ github.event.inputs.version }}'
17+
steps:
18+
- name: Get auth token
19+
id: token
20+
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
21+
with:
22+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
23+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
24+
25+
- name: Check out current commit (${{ github.sha }})
26+
uses: actions/checkout@v4
27+
with:
28+
token: ${{ steps.token.outputs.token }}
29+
fetch-depth: 0
30+
31+
- name: Prepare release ${{ github.event.inputs.version }}
32+
uses: getsentry/action-prepare-release@v1
33+
env:
34+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
35+
with:
36+
version: ${{ github.event.inputs.version }}
37+
force: ${{ github.event.inputs.force }}

CHANGELOG.md

Whitespace-only changes.

scripts/bump-version.ps1

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Param(
2+
[Parameter(Mandatory = $true)][String]$prevVersion,
3+
[Parameter(Mandatory = $true)][String]$newVersion
4+
)
5+
Set-StrictMode -Version latest
6+
7+
$sconsFile = "$PSScriptRoot/../SConstruct"
8+
$content = Get-Content $sconsFile
9+
$content -replace 'VERSION = ".*"', ('VERSION = "' + $newVersion + '"') | Out-File $sconsFile
10+
11+
# Check that the version was updated.
12+
if ("$content" -eq "$(Get-Content $sconsFile)")
13+
{
14+
$versionInFile = [regex]::Match("$content", 'VERSION = "([^"]+)"').Groups[1].Value
15+
if ("$versionInFile" -ne "$newVersion")
16+
{
17+
Throw "Failed to update version in $sconsFile - the content didn't change. The version found in the file is '$versionInFile'."
18+
}
19+
}

0 commit comments

Comments
 (0)