Skip to content

Commit e4589d6

Browse files
Merge pull request #35 from thomaseizinger/release/2.0.0
2 parents 1f4006d + 36e4d41 commit e4589d6

File tree

8 files changed

+46
-86
lines changed

8 files changed

+46
-86
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 17 additions & 24 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,34 +32,35 @@ 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
58-
with:
50+
env:
5951
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60-
head: release/${{ env.RELEASE_VERSION }}
52+
with:
53+
head: release/${{ github.event.inputs.version }}
6154
base: master
62-
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+
title: Release version ${{ github.event.inputs.version }}
56+
reviewers: ${{ github.actor }} # By default, we request a review from the person who triggered the workflow.
6457
# Write a nice message to the user.
6558
# We are claiming things here based on the `publish-new-release.yml` workflow.
6659
# You should obviously adopt it to say the truth depending on your release workflow :)
6760
body: |
68-
Hi @${{ github.event.issue.user.login }}!
61+
Hi @${{ github.actor }}!
6962
70-
This PR was created in response to this release issue: #${{ github.event.issue.number }}.
63+
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
7164
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
7265
7366
Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.

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

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,15 @@ jobs:
1919
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
2020
VERSION=${BRANCH_NAME#release/}
2121
22-
echo "::set-env name=RELEASE_VERSION::$VERSION"
22+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
2323
2424
- name: Extract version from branch name (for hotfix branches)
2525
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
2626
run: |
2727
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
2828
VERSION=${BRANCH_NAME#hotfix/}
2929
30-
echo "::set-env name=RELEASE_VERSION::$VERSION"
31-
32-
# Unfortunately, GitHub doesn't trigger events for actions that have been taken by a GitHub action.
33-
# This means we cannot use `Fixes #issue_number.` in the body of the PR to close the release issue after the branch is merged.
34-
# Hence, we close it here "manually"
35-
- name: Close release issue
36-
run: |
37-
RELEASE_ISSUE_URL=$(curl https://api.github.com/repos/${{ github.repository }}/issues\?labels=release\&state=open | jq -r '.[0].url')
38-
39-
curl \
40-
-X PATCH \
41-
-H 'Accept: application/vnd.github.v3+json' \
42-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
43-
-H "Content-Type: application/json" \
44-
$RELEASE_ISSUE_URL \
45-
-d '{"state":"closed"}'
30+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
4631
4732
- name: Create Release
4833
uses: thomaseizinger/create-release@1.0.0
@@ -55,15 +40,16 @@ jobs:
5540
draft: false
5641
prerelease: false
5742

58-
- name: Merge release into dev branch
43+
- name: Merge master into dev branch
5944
uses: thomaseizinger/create-pull-request@1.0.0
60-
with:
45+
env:
6146
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
head: release/${{ env.RELEASE_VERSION }}
47+
with:
48+
head: master
6349
base: dev
64-
title: Merge release ${{ env.RELEASE_VERSION }} into dev branch
50+
title: Merge master into dev branch
6551
body: |
66-
This PR merges the release branch for ${{ env.RELEASE_VERSION }} back into dev.
52+
This PR merges the master branch back into dev.
6753
This happens to ensure that the updates that happend on the release branch, i.e. CHANGELOG and manifest updates are also present on the dev branch.
6854
6955
# if needed, you can checkout the latest master here, build artifacts and publish / deploy them somewhere

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

CHANGELOG.md

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

88
## [Unreleased]
99

10+
## [2.0.0] - 2020-10-17
11+
12+
### Changed
13+
14+
- Use `workflow_dispatch` instead of opening an issue as the initial trigger of the release.
15+
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.
16+
- Merge `master` in `dev` after a release branch is merged.
17+
Previously, we used to merge the `release` branch back into `dev`.
18+
However, this caused some issues because the actual merge commit was not present in the `dev` branch.
19+
It also prevented use of the "automatically delete head branch" feature of GitHub which works well together with the "PR retargeting" feature.
20+
1021
## [1.4.0] - 2020-02-22
1122

1223
### Added
@@ -43,7 +54,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4354

4455
- Everything since the beginning!
4556

46-
[Unreleased]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.4.0...HEAD
57+
[Unreleased]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/2.0.0...HEAD
58+
59+
[2.0.0]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.4.0...2.0.0
4760

4861
[1.4.0]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.3.0...1.4.0
4962

README.md

Lines changed: 5 additions & 2 deletions
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:
@@ -18,7 +18,10 @@ The automation will do the following things:
1818

1919
## Design
2020

21-
I've written a blog post that describes the technical design in detail here: https://blog.eizinger.io/12274/using-github-actions-to-automate-gitflow-style-releases
21+
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
22+
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.
2225

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

index.test.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
{
22
"name": "github-action-gitflow-release-workflow",
3-
"version": "1.4.0",
3+
"version": "2.0.0",
44
"main": "index.js",
55
"author": "Thomas Eizinger <thomas@eizinger.io>",
6-
"license": "MIT",
7-
"scripts": {
8-
"test": "jest"
9-
},
10-
"devDependencies": {
11-
"jest": "^24.9.0"
12-
}
6+
"license": "MIT"
137
}

0 commit comments

Comments
 (0)