Skip to content

Commit 1fd49eb

Browse files
feat: make actions send a PR instead of push to main (#340)
* releases: pr instead of push into main directly * releases: adds release_create for testing * releases: use startsWith instead * releases: remove actions as requirement * releases: trigger actions only on pr authored by github actions * releases: trying to tcheck actions's commiter email * releases: remove commiter trial * releases: make release-script-tests a reusable workflow * releases: adds extra permissions + run create_release script * releases: adds missing github token * releases: fix fbug on first releases * releases: refactoring to include co-authors + adds type hints * releases: specify dependency versions in requirements.txt * releases: types based on classes instead of modules * releases: remove cache python dependencies * releases: fix requirements.txt install location * releases: not list release pull rrequests * releases: fix capital C * releases: adds missing end of line * releases: use commit hash instead of version directly for peter-evans/create-pull-request * releases: change pytest level of verbosity to be just -v * releases: remove release.yml workflow * releases: format release.py * releases: adds check for pull request created by actions bot * releases: run create-release workflow only if pull_request.user.login starts with 'github-actions' * releases: run create-release workflow only if pull_request.user.login starts with 'github-actions' * releases: adds flake8-annotations rule * releaseS: adds missing && in release_create.yml * releases: add missing test + missing condition to PRs for next release
1 parent 77c170b commit 1fd49eb

File tree

11 files changed

+714
-320
lines changed

11 files changed

+714
-320
lines changed

.github/workflows/release-script-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Release Script Tests
22

33
on:
4+
# workflow_call is used to indicate that a workflow can be called by another workflow.
5+
workflow_call:
46
push:
57
branches:
68
- "*"

.github/workflows/release.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release Create Workflow
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
contents: write
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
jobs:
14+
release-script-test:
15+
uses: ./.github/workflows/release-script-tests.yml
16+
17+
create-release:
18+
needs: release-script-test
19+
runs-on: ubuntu-latest
20+
if: >
21+
${{ needs.release-script-test.result == 'success' }} &&
22+
github.event.pull_request.merged == true &&
23+
github.event.pull_request.base.ref == 'main' &&
24+
startsWith(github.event.pull_request.head.ref, 'release/v') &&
25+
startsWith(github.event.pull_request.user.login, 'github-actions')
26+
27+
env:
28+
NEXT_RELEASE_TAG: ${{ github.event.pull_request.head.ref }}
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
32+
33+
- name: Install dependencies
34+
run: pip3 install -r ./tools/release/requirements.txt
35+
36+
- name: Extract Tag from branch name
37+
run: |
38+
NEXT_RELEASE_TAG=$(echo $NEXT_RELEASE_TAG | sed 's/^release\///')
39+
echo "NEXT_RELEASE_TAG=${NEXT_RELEASE_TAG}" >> $GITHUB_ENV
40+
41+
- name: Target release Tag
42+
run: echo "New tag $NEXT_RELEASE_TAG"
43+
44+
- name: Amalgamation
45+
run: ./singleheader/amalgamate.py
46+
47+
- name: "Create release"
48+
run: ./tools/release/create_release.py
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release Prepare Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
type: string
8+
required: true
9+
description: "Tag for the next release. Ex.: v5.0.0"
10+
11+
env:
12+
NEXT_RELEASE_TAG: ${{ github.event.inputs.tag }}
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
jobs:
20+
release-script-test:
21+
uses: ./.github/workflows/release-script-tests.yml
22+
23+
prepare-release-and-pull-request:
24+
needs: release-script-test
25+
runs-on: ubuntu-latest
26+
if: ${{ needs.release-script-test.result == 'success' }}
27+
env:
28+
CXX: clang++-14
29+
steps:
30+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
31+
32+
- name: Install dependencies
33+
run: pip3 install -r ./tools/release/requirements.txt
34+
35+
- name: Update source code versions
36+
run: ./tools/release/update_versions.py
37+
38+
- name: Ada Build
39+
run: cmake -B build && cmake --build build
40+
- name: Ada Test
41+
run: ctest --output-on-failure --test-dir build
42+
43+
- name: Create PR with code updates for new release
44+
uses: peter-evans/create-pull-request@f3a21bf3404eae73a97f65817ab35f351a1a63fe #v5.0.0
45+
with:
46+
commit-message: "chore: release ${{ env.NEXT_RELEASE_TAG }}"
47+
branch: "release/${{ env.NEXT_RELEASE_TAG }}"
48+
title: "chore: release ${{ env.NEXT_RELEASE_TAG }}"
49+
token: ${{ env.GITHUB_TOKEN }}
50+
body: |
51+
This pull PR updates the source code version to ${{ env.NEXT_RELEASE_TAG }}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ select = [
1616
"TID", # flake8-tidy-imports
1717
"W", # pycodestyle
1818
"YTT", # flake8-2020
19+
"ANN" # flake8-annotations
1920
]
2021
exclude = [
2122
"docs",

0 commit comments

Comments
 (0)