Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Make flank release more automatically #1352

Merged
merged 8 commits into from
Nov 27, 2020
Merged
34 changes: 34 additions & 0 deletions .github/workflows/create_new_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Create new release

on:
pull_request:
types: [ closed ]

jobs:
create_release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This job can be triggered by any merged PR with a specific label (which can be added manually). (I can create PR compromised PR, add release label and merge it. If I understand the job description correctly -- it will start release)

If I am not wrong, release notes PR is created by a bot, I think we should consider adding an additional condition which verifies who is the creator or merged PR.

It's the first that came to my mind, if there is a better way to make it more secure I think it would be worth to implement it.

Of course, let me know, I might be wrong and this implementation is already secure 💪

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are 100% right that if someone uses release label it will generate new release,
I think that we could make additional check if issue is created by bot and/or check if title starts with chore: release notes for

steps:
- uses: actions/checkout@v2
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.FLANK_RELEASE_APP_ID }}
private_key: ${{ secrets.FLANK_RELEASE_PRIVATE_KEY }}

- name: Gradle Build flankScripts and add it to PATH
run: |
./flank-scripts/bash/buildFlankScripts.sh
echo "./flank-scripts/bash" >> $GITHUB_PATH
- name: Set next release tag variable
run: |
TAG=$(flankScripts ci nextReleaseTag --token=${{ secrets.GITHUB_TOKEN }})
echo "NEXT_RELEASE_TAG=$(echo $TAG)" >> $GITHUB_ENV

- name: Push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5
with:
github_token: ${{ steps.generate-token.outputs.token }}
custom_tag: ${{ env.NEXT_RELEASE_TAG }}
tag_prefix: ''
2 changes: 2 additions & 0 deletions .github/workflows/release_notes_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: "Generate release notes for next commit"

on:
workflow_dispatch:
schedule:
- cron: 0 7 1 * *

jobs:
generateReleaseNotes:
Expand Down
11 changes: 9 additions & 2 deletions docs/release_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ Each push:
- to `master` branch run Snapshot release
- of tag `v*` run regular release

## Manual Steps
## Triggering release

### Manually
1. Navigate to [Github Actions](https://github.com/Flank/flank/actions)
2. Run job [`Generate release notes for next commit`](https://github.com/Flank/flank/actions?query=workflow%3A%22Generate+release+notes+for+next+commit%22) by using `Run Workflow` button
3. After merging, push a tag for the release
3. After merging PR, the next tag will be pushed to repository
4. Wait for CI job to finish

### Automatically
1. Release job will run each 1st day of month
2. After merging PR, the next tag will be pushed to repository
2. Wait for CI job to finish

## CI Steps
1. Gradle Build flankScripts and add it to PATH
2. Set environment variables
Expand Down