Skip to content

Commit

Permalink
feat: make actions send a PR instead of push to main (ada-url#340)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
miguelteixeiraa authored Apr 26, 2023
1 parent 77c170b commit 1fd49eb
Show file tree
Hide file tree
Showing 11 changed files with 714 additions and 320 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release-script-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Release Script Tests

on:
# workflow_call is used to indicate that a workflow can be called by another workflow.
workflow_call:
push:
branches:
- "*"
Expand Down
84 changes: 0 additions & 84 deletions .github/workflows/release.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/release_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release Create Workflow

on:
pull_request:
types: [closed]

permissions:
contents: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
release-script-test:
uses: ./.github/workflows/release-script-tests.yml

create-release:
needs: release-script-test
runs-on: ubuntu-latest
if: >
${{ needs.release-script-test.result == 'success' }} &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main' &&
startsWith(github.event.pull_request.head.ref, 'release/v') &&
startsWith(github.event.pull_request.user.login, 'github-actions')
env:
NEXT_RELEASE_TAG: ${{ github.event.pull_request.head.ref }}
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

- name: Install dependencies
run: pip3 install -r ./tools/release/requirements.txt

- name: Extract Tag from branch name
run: |
NEXT_RELEASE_TAG=$(echo $NEXT_RELEASE_TAG | sed 's/^release\///')
echo "NEXT_RELEASE_TAG=${NEXT_RELEASE_TAG}" >> $GITHUB_ENV
- name: Target release Tag
run: echo "New tag $NEXT_RELEASE_TAG"

- name: Amalgamation
run: ./singleheader/amalgamate.py

- name: "Create release"
run: ./tools/release/create_release.py
51 changes: 51 additions & 0 deletions .github/workflows/release_prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release Prepare Workflow

on:
workflow_dispatch:
inputs:
tag:
type: string
required: true
description: "Tag for the next release. Ex.: v5.0.0"

env:
NEXT_RELEASE_TAG: ${{ github.event.inputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: write
pull-requests: write

jobs:
release-script-test:
uses: ./.github/workflows/release-script-tests.yml

prepare-release-and-pull-request:
needs: release-script-test
runs-on: ubuntu-latest
if: ${{ needs.release-script-test.result == 'success' }}
env:
CXX: clang++-14
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

- name: Install dependencies
run: pip3 install -r ./tools/release/requirements.txt

- name: Update source code versions
run: ./tools/release/update_versions.py

- name: Ada Build
run: cmake -B build && cmake --build build
- name: Ada Test
run: ctest --output-on-failure --test-dir build

- name: Create PR with code updates for new release
uses: peter-evans/create-pull-request@f3a21bf3404eae73a97f65817ab35f351a1a63fe #v5.0.0
with:
commit-message: "chore: release ${{ env.NEXT_RELEASE_TAG }}"
branch: "release/${{ env.NEXT_RELEASE_TAG }}"
title: "chore: release ${{ env.NEXT_RELEASE_TAG }}"
token: ${{ env.GITHUB_TOKEN }}
body: |
This pull PR updates the source code version to ${{ env.NEXT_RELEASE_TAG }}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ select = [
"TID", # flake8-tidy-imports
"W", # pycodestyle
"YTT", # flake8-2020
"ANN" # flake8-annotations
]
exclude = [
"docs",
Expand Down
Loading

0 comments on commit 1fd49eb

Please sign in to comment.