Skip to content

Commit

Permalink
Merge pull request #714 from postmanlabs/feature/automate-releases
Browse files Browse the repository at this point in the history
Using GitHub Actions to automate releases
  • Loading branch information
Dhwaneet Bhatt committed May 4, 2023
2 parents d1762bf + 60ccabf commit 623092d
Show file tree
Hide file tree
Showing 4 changed files with 4,490 additions and 2,642 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Draft new release

on:
workflow_dispatch:
inputs:
version:
description: The version you want to release. Must be a valid semver version.
required: true
type: string

jobs:
draft-new-release:
if: startsWith(github.event.inputs.version, 'v')
name: Draft a new release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Create release branch
run: git checkout -b release/${{ github.event.inputs.version }}

- name: Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@1.1.0
with:
version: ${{ github.event.inputs.version }}

- name: Initialize mandatory git config
run: |
git config user.name "GitHub Actions"
git config user.email noreply@github.com
- name: Bump version
run: npm version ${{ github.event.inputs.version }} --git-tag-version false

- name: Commit changelog and manifest files
id: make-commit
run: |
git add CHANGELOG.md package.json package-lock.json
git commit --message "Prepare release ${{ github.event.inputs.version }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push new branch
run: git push origin release/${{ github.event.inputs.version }}

- name: Create pull request for master
uses: thomaseizinger/create-pull-request@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head: release/${{ github.event.inputs.version }}
base: master
title: "Release version ${{ github.event.inputs.version }}"
reviewers: ${{ github.actor }}
body: |
Hi @${{ github.actor }}!
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 }}.
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
- name: Create pull request for develop
uses: thomaseizinger/create-pull-request@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head: release/${{ github.event.inputs.version }}
base: develop
title: "Release version ${{ github.event.inputs.version }}"
reviewers: ${{ github.actor }}
body: |
Hi @${{ github.actor }}!
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 }}.
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
28 changes: 19 additions & 9 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
name: Test

on:
[pull_request]
push:
branches: [develop, master]
pull_request:

jobs:
Unit-Tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: '14.x'
- run: npm install
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run test-lint
- run: npm run test-system
- run: npm run test-unit

Regression:
needs: Unit-Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: '14.x'
- run: npm install
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run test-regression
46 changes: 46 additions & 0 deletions .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Publish new release"

on:
pull_request:
branches:
- master
types:
- closed

jobs:
release:
name: Publish new release
runs-on: ubuntu-latest
# only merged pull requests that begin with 'release/' or 'hotfix/' must trigger this job
if: github.event.pull_request.merged == true &&
(contains(github.event.pull_request.head.ref, 'release/') || contains(github.event.pull_request.head.ref, 'hotfix/'))
permissions:
contents: write

steps:
- name: Extract version from branch name (for release branches)
if: contains(github.event.pull_request.head.ref, 'release/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract version from branch name (for hotfix branches)
if: contains(github.event.pull_request.head.ref, 'hotfix/')
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Release
uses: thomaseizinger/create-release@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
tag_name: ${{ env.RELEASE_VERSION }}
name: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
Loading

0 comments on commit 623092d

Please sign in to comment.