-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (75 loc) · 2.78 KB
/
release-test.yaml
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
77
78
name: Release Test Checks
on:
push:
branches:
- release-test
jobs:
build-release:
name: Build a release for the module
runs-on: ubuntu-latest
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Bump version and create changelog
id: bump
uses: commitizen-tools/commitizen-action@master
with:
push: false
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: release.md
git_redirect_stderr: true
- name: Output the new version number
run: echo '${{ steps.bump.outputs.version }}'
- name: Get the module name
id: module_name
run: |
REPO_NAME="${{ github.event.repository.name }}"
REPO_NAME="${REPO_NAME/tofu-modules-/}"
MODULE_NAME="${REPO_NAME//-/_}"
echo "name=${MODULE_NAME}" >> $GITHUB_OUTPUT
- name: Output the module name
run: echo '${{ steps.module_name.outputs.name }}'
- name: Get the commit message
id: message
run: |
MESSAGE=$(git log --format=%B -n 1)
echo "message=${MESSAGE}" >> $GITHUB_OUTPUT
- name: Open a pull request for the release
uses: peter-evans/create-pull-request@v7
with:
branch: release-${{ steps.bump.outputs.version }}
title: ${{ steps.message.outputs.message }}
release:
name: Build a release for the module
runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'bump:')
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Print commit message
run: echo '${{ github.event.head_commit.message }}'
- name: Determine the new version number
id: version
uses: actions/github-script@v7
with:
# Look for the last version number, expecting it to be in the format:
# `#.#.#-<suffix>.#` where the suffix is optional.
script: |
const message = 'bump: version 0.1.0 → 0.1.1 (#1)'
const regex = /^bump:.+(?<version>\d+\.\d+\.\d+[\da-z.-]*) \(#\d+\)$/
const version = message.match(regex).groups.version
console.log(version)
return version
- name: Output the new version number
run: echo '${{ steps.version.outputs.result }}'
- name: Bump version and create changelog
id: bump
uses: commitizen-tools/commitizen-action@master
with:
push: false
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: release.md
git_redirect_stderr: true
- name: Output the new version number
run: echo '${{ steps.bump.outputs.version }}'