diff --git a/.github/workflows/draft-new-release.yml b/.github/workflows/draft-new-release.yml index b382050..6d3eb02 100644 --- a/.github/workflows/draft-new-release.yml +++ b/.github/workflows/draft-new-release.yml @@ -27,20 +27,26 @@ jobs: with: version: ${{ env.RELEASE_VERSION }} + # In order to make a commit, we need to initialize a user. + # You may choose to write something less generic here if you want, it doesn't matter functionality wise. - name: Initialize mandatory git config run: | git config user.name "GitHub actions" git config user.email noreply@github.com # This step will differ depending on your project setup + # Fortunately, yarn has a built-in command for doing this! - name: Bump version in package.json run: yarn version --new-version ${{ env.RELEASE_VERSION }} --no-git-tag-version - name: Commit changelog and manifest files + id: make-commit run: | git add CHANGELOG.md package.json git commit --message "Prepare release ${{ env.RELEASE_VERSION }}" + echo "::set-output name=commit::$(git rev-parse HEAD)" + - name: Push new branch run: git push origin release/${{ env.RELEASE_VERSION }} @@ -51,6 +57,14 @@ jobs: head: release/${{ env.RELEASE_VERSION }} base: master title: ${{ github.event.issue.title }} - reviewers: ${{ github.event.issue.user.login }} + 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. + # Write a nice message to the user. + # We are claiming things here based on the `publish-new-release.yml` workflow. + # You should obviously adopt it to say the truth depending on your release workflow :) body: | - Resolves #${{ github.event.issue.number }} + Hi ${{ github.event.issue.user.login }}! + + This PR was created in response to this release issue: #${{ github.event.issue.number }}. + I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}. + + Merging this PR will create a GitHub release and upload any assets that are created as part of the release build. diff --git a/.github/workflows/publish-new-release.yml b/.github/workflows/publish-new-release.yml index 7a07101..2ef95db 100644 --- a/.github/workflows/publish-new-release.yml +++ b/.github/workflows/publish-new-release.yml @@ -29,14 +29,32 @@ jobs: echo "::set-env name=RELEASE_VERSION::$VERSION" + # Unfortunately, GitHub doesn't trigger events for actions that have been taken by a GitHub action. + # This means we cannot use `Fixes #issue_number.` in the body of the PR to close the release issue after the branch is merged. + # Hence, we close it here "manually" + - name: Close release issue + run: | + + RELEASE_ISSUE_URL=$(curl https://api.github.com/repos/${{ github.repository }}/issues?labels=release&state=open | jq -r '.[1].url') + + curl \ + -X PATCH \ + -H 'Accept: application/vnd.github.v3+json' \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + $RELEASE_ISSUE_URL \ + -d '{"state":"closed"}' + - name: Create Release - uses: fleskesvor/create-release@feature/support-target-commitish + uses: thomaseizinger/create-release@1.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - commitish: ${{ github.event.pull_request.merge_commit_sha }} + target_commitish: ${{ github.event.pull_request.merge_commit_sha }} tag_name: ${{ env.RELEASE_VERSION }} - release_name: ${{ env.RELEASE_VERSION }} + name: ${{ env.RELEASE_VERSION }} + draft: false + prerelease: false - name: Merge release into dev branch uses: thomaseizinger/create-pull-request@1.0.0 @@ -45,5 +63,9 @@ jobs: head: release/${{ env.RELEASE_VERSION }} base: dev title: Merge release ${{ env.RELEASE_VERSION }} into dev branch + body: | + This PR merges the release branch for ${{ env.RELEASE_VERSION }} back into dev. + 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. # if needed, you can checkout the latest master here, build artifacts and publish / deploy them somewhere + # the create-release action has an output `upload_url` output that you can use to upload assets diff --git a/CHANGELOG.md b/CHANGELOG.md index f0520ce..67372c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.3.0] - 2020-02-22 + ## [1.2.0] - 2020-02-17 ### Changed @@ -31,7 +33,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Everything since the beginning! -[Unreleased]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.2.0...HEAD +[Unreleased]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.3.0...HEAD + +[1.3.0]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.2.0...1.3.0 [1.2.0]: https://github.com/thomaseizinger/github-action-gitflow-release-workflow/compare/1.1.0...1.2.0 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..64403f1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2020 Thomas Eizinger + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7766945 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# GitFlow release workflow using GitHub actions + +This repository contains GitHub workflows that allow for fully automated release as per the GitFlow conventions. +You are welcome to use it for inspiration for your own release workflows or maybe even copying them verbatim if the fit your needs. + +## Usage + +If you are using the workflows as they are in this repository, there are only two manual steps for releasing a new version: + +1. Create a ticket that is titled "Release version x.y.z" and label it with "release". +2. Merge the PR that is created for you. + +The automation will do the following things: + +- Update your changelog with the new version +- Change the version in the necessary manifest files +- Tag the final release and create a GitHub release + +## Design + +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 + +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. + +I think I've achieved this by doing the following: + +- The individual GitHub actions used are small and focused. + +This allows you to adapt the workflows to your own needs. +Ironically, this is what makes this whole repository not special. +It just takes good ideas that are already out there and creates automation around them. + +- You have full control over what the next version is. + +There is no magic involved, only the tedious things are automated. +You have full control over what is being released and under which version. + +## Hall of fame + +If you are using these workflow or got inspired by them to build something similar, feel free to add yourself to this list: + +- BE THE FIRST ONE! + +## License + +MIT. diff --git a/package.json b/package.json index daa533e..798c4a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-action-gitflow-release-workflow", - "version": "1.2.0", + "version": "1.3.0", "main": "index.js", "author": "Thomas Eizinger ", "license": "MIT",