Skip to content

Commit 353727a

Browse files
Convert draft-new-release workflow to use workflow_dispatch
1 parent 57cc7cd commit 353727a

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

.github/workflows/draft-new-release.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
name: "Draft new release"
22

33
on:
4-
issues:
5-
types: [opened, labeled]
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The version you want to release.'
8+
required: true
69

710
jobs:
811
draft-new-release:
912
name: "Draft a new release"
1013
runs-on: ubuntu-latest
11-
# Only run for issues with a specific title and label. Not strictly required but makes finding the release issue again later easier.
12-
# There is also a whitelist that you may want to use to restrict, who can trigger this workflow.
13-
# Unfortunately, we cannot create an array on the fly, so the whitelist is just comma-separated.
14-
if: startsWith(github.event.issue.title, 'Release version') && contains(github.event.issue.labels.*.name, 'release') && contains('thomaseizinger,yourusername', github.event.issue.user.login)
1514
steps:
1615
- uses: actions/checkout@v2
1716

18-
- name: Extract version from issue title
19-
run: |
20-
TITLE="${{ github.event.issue.title }}"
21-
VERSION=${TITLE#Release version }
22-
23-
echo "::set-env name=RELEASE_VERSION::$VERSION"
24-
2517
- name: Create release branch
26-
run: git checkout -b release/${{ env.RELEASE_VERSION }}
18+
run: git checkout -b release/${{ github.event.inputs.version }}
2719

2820
- name: Update changelog
2921
uses: thomaseizinger/keep-a-changelog-new-release@1.1.0
3022
with:
31-
version: ${{ env.RELEASE_VERSION }}
23+
version: ${{ github.event.inputs.version }}
3224

3325
# In order to make a commit, we need to initialize a user.
3426
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
@@ -40,32 +32,32 @@ jobs:
4032
# This step will differ depending on your project setup
4133
# Fortunately, yarn has a built-in command for doing this!
4234
- name: Bump version in package.json
43-
run: yarn version --new-version ${{ env.RELEASE_VERSION }} --no-git-tag-version
35+
run: yarn version --new-version ${{ github.event.inputs.version }} --no-git-tag-version
4436

4537
- name: Commit changelog and manifest files
4638
id: make-commit
4739
run: |
4840
git add CHANGELOG.md package.json
49-
git commit --message "Prepare release ${{ env.RELEASE_VERSION }}"
41+
git commit --message "Prepare release ${{ github.event.inputs.version }}"
5042
5143
echo "::set-output name=commit::$(git rev-parse HEAD)"
5244
5345
- name: Push new branch
54-
run: git push origin release/${{ env.RELEASE_VERSION }}
46+
run: git push origin release/${{ github.event.inputs.version }}
5547

5648
- name: Create pull request
5749
uses: thomaseizinger/create-pull-request@1.0.0
5850
with:
5951
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60-
head: release/${{ env.RELEASE_VERSION }}
52+
head: release/${{ github.event.inputs.version }}
6153
base: master
6254
title: ${{ github.event.issue.title }}
63-
reviewers: ${{ github.event.issue.user.login }} # By default, we request a review from the person who opened the issue. You can replace this with a static list of users.
55+
reviewers: ${{ github.actor }} # By default, we request a review from the person who triggered the workflow.
6456
# Write a nice message to the user.
6557
# We are claiming things here based on the `publish-new-release.yml` workflow.
6658
# You should obviously adopt it to say the truth depending on your release workflow :)
6759
body: |
68-
Hi @${{ github.event.issue.user.login }}!
60+
Hi @${{ github.actor }}!
6961
7062
This PR was created in response to this release issue: #${{ github.event.issue.number }}.
7163
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Use `workflow_dispatch` instead of opening an issue as the initial trigger of the release.
13+
Not only is this more convenient to use, it also fixes a security vulnerability that may have allowed users without write access to execute arbitrary code within the context of the repositories GitHub action.
14+
1015
## [1.4.0] - 2020-02-22
1116

1217
### Added

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ You are welcome to use it for inspiration for your own release workflows or mayb
77

88
If you are using the workflows as they are in this repository, there are only two manual steps for releasing a new version:
99

10-
1. Create a ticket that is titled "Release version x.y.z" and label it with "release".
10+
1. Trigger the "Draft new release" workflow through the "Actions" tab.
1111
2. Merge the PR that is created for you.
1212

1313
The automation will do the following things:
@@ -20,6 +20,9 @@ The automation will do the following things:
2020

2121
I've written a blog post that describes the technical design in detail here: https://blog.eizinger.io/12274/using-github-actions-and-gitflow-to-automate-your-release-process
2222

23+
NOTE: The workflows and actions in this repository were changed since the blogpost was published.
24+
Please see the CHANGELOG.md for a detailed summary.
25+
2326
The idea of these workflows is to automate all the tedious aspects of releases while still allowing manual intervention if necessary and control over crucial aspects.
2427

2528
I think I've achieved this by doing the following:

0 commit comments

Comments
 (0)