Skip to content

Commit 150cc47

Browse files
committed
chore: add Release Please GHA workflow
1 parent d499aa9 commit 150cc47

File tree

14 files changed

+48
-202
lines changed

14 files changed

+48
-202
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ on:
66
paths-ignore:
77
- '**.md'
88
- 'docs/**'
9+
- .github/**
10+
- '!.github/workflows/ci.yml'
911
push:
1012
branches:
1113
- main
1214
paths-ignore:
1315
- '**.md'
1416
- 'docs/**'
17+
- .github/**
18+
- '!.github/workflows/ci.yml'
1519

1620
permissions:
1721
contents: read

.github/workflows/release-prepare.yml

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

.github/workflows/release.yml

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,38 @@
1-
name: Release Create
1+
name: Release Please
22

33
on:
4-
pull_request:
5-
types: [closed]
4+
push:
5+
branches:
6+
- main
67

7-
env:
8-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8+
permissions:
9+
contents: read
910

1011
jobs:
11-
check-release-conditions:
12+
release-please:
1213
runs-on: ubuntu-latest
13-
if: |
14-
github.event.pull_request.merged == true &&
15-
github.event.pull_request.base.ref == 'main' &&
16-
startsWith(github.event.pull_request.head.ref, 'release/v') &&
17-
startsWith(github.event.pull_request.user.login, 'github-actions')
18-
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
outputs:
18+
release_created: ${{ steps.release.outputs.release_created }}
19+
release_tag: ${{ steps.release.outputs.tag_name }}
1920
steps:
20-
- name: Check release conditions
21-
run: |
22-
echo "All conditions have been met!"
21+
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
22+
id: release
2323

2424
create-release:
2525
permissions:
2626
contents: write
27-
needs: check-release-conditions
27+
needs: release-please
28+
if: ${{ needs.release-please.outputs.release_created }}
2829
runs-on: ubuntu-latest
2930

30-
env:
31-
NEXT_RELEASE_TAG: ${{ github.event.pull_request.head.ref }}
3231
steps:
3332
- name: Checkout
34-
uses: actions/checkout@v4
35-
36-
- name: Prepare Python
37-
uses: actions/setup-python@v5
33+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3834
with:
39-
cache: 'pip'
40-
41-
- name: Install dependencies
42-
run: pip install -r ./tools/release/requirements.txt
43-
44-
- name: Extract Tag from branch name
45-
run: |
46-
NEXT_RELEASE_TAG=$(echo $NEXT_RELEASE_TAG | sed 's/^release\///')
47-
echo "NEXT_RELEASE_TAG=${NEXT_RELEASE_TAG}" >> $GITHUB_ENV
48-
49-
- name: Target release Tag
50-
run: echo "New tag $NEXT_RELEASE_TAG"
35+
persist-credentials: false
5136

5237
- name: Setup Ninja
5338
run: sudo apt-get install ninja-build
@@ -65,4 +50,7 @@ jobs:
6550
cp merve.h merve.cpp ../../singleheader/
6651
6752
- name: Create release
68-
run: ./tools/release/create_release.py
53+
run: gh release upload "$RELEASE_TAG" singleheader/*
54+
env:
55+
GH_TOKEN: ${{ github.token }}
56+
RELEASE_TAG: ${{ needs.release-please.outputs.release_tag }}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.0.0"
3+
}

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ cmake_minimum_required(VERSION 3.16)
33
project(merve
44
DESCRIPTION "Fast lexer to extract named exports via analysis from CommonJS modules"
55
LANGUAGES C CXX
6-
VERSION 1.0.0
6+
VERSION 1.0.0 # x-release-please-version
77
)
88

9-
set(MERVE_LIB_VERSION "1.0.0" CACHE STRING "lexer library version")
10-
set(MERVE_LIB_SOVERSION "1" CACHE STRING "lexer library soversion")
9+
set(MERVE_LIB_VERSION "1.0.0" CACHE STRING "lexer library version") # x-release-please-version
10+
set(MERVE_LIB_SOVERSION "1" CACHE STRING "lexer library soversion") # x-release-please-major
1111

1212
include(GNUInstallDirs)
1313

include/merve/version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
#ifndef MERVE_VERSION_H
66
#define MERVE_VERSION_H
77

8-
#define MERVE_VERSION "1.0.0"
8+
#define MERVE_VERSION "1.0.0" // x-release-please-version
99

1010
namespace lexer {
1111

1212
enum {
13-
MERVE_VERSION_MAJOR = 1,
14-
MERVE_VERSION_MINOR = 0,
15-
MERVE_VERSION_REVISION = 0,
13+
MERVE_VERSION_MAJOR = 1, // x-release-please-major
14+
MERVE_VERSION_MINOR = 0, // x-release-please-minor
15+
MERVE_VERSION_REVISION = 0, // x-release-please-patch
1616
};
1717

1818
} // namespace lexer

release-please-config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"packages": {
3+
".": {
4+
"release-type": "simple",
5+
"extra-files": [
6+
"CMakeLists.txt",
7+
"include/lexer/version.h"
8+
]
9+
}
10+
}
11+
}

tools/release/__init__.py

Whitespace-only changes.

tools/release/create_release.py

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

tools/release/lib/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)