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

Update GitHub Actions workflows #79

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/draft-a-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ jobs:
run: git push origin ${{ env.BRANCH }}

- name: Create a Pull Request
uses: thomaseizinger/[email protected]
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
base: master
head: ${{ env.BRANCH }}
title: Release version ${{ env.VERSION }}
script: |
const { owner, repo } = context.repo;
const version = process.env.VERSION;
const title = 'Release version ' + version;
const body = 'Created by GitHub Actions';
const base = 'master';
const head = process.env.BRANCH;

github.rest.pulls.create({
owner,
repo,
title,
body,
base,
head
});
68 changes: 47 additions & 21 deletions .github/workflows/publish-a-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Publish Release to GitHub

on:
pull_request:
branches:
Expand All @@ -10,31 +11,56 @@ jobs:
publish-a-release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')

steps:
- name: Extract version from branch name (for release branches)
if: startsWith(github.event.pull_request.head.ref, 'release/')
- name: Extract version from branch name
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV

- name: Create Release
uses: thomaseizinger/[email protected]
env:
set -x
branchName="${{ github.event.pull_request.head.ref }}"
version=${branchName#release/}
if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-rc\.([0-9]+))?$ ]]; then
echo "TAG=$version" >> $GITHUB_ENV
else
echo "$version is not a supported semver." >&2
exit 1
fi

- name: Create Release to GitHub
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
tag_name: ${{ env.RELEASE_VERSION }}
name: v${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
script: |
const { owner, repo } = context.repo;
const target_commitish = context.sha;

- name: Merge master into develop branch (Gitflow)
uses: thomaseizinger/[email protected]
env:
github.rest.repos.createRelease({
owner,
repo,
tag_name: process.env.TAG,
target_commitish,
name: `v${process.env.TAG}`,
generate_release_notes: true,
draft: process.env.TAG.includes('-rc'),
prerelease: false
});

- name: Create a PR to merge master back into develop branch
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head: master
base: develop
title: Merge master into develop branch (Gitflow)
script: |
const { owner, repo } = context.repo;
const title = `Merge master into develop after publishing release ${process.env.TAG}`;
const body = 'Created by GitHub Actions';
const base = 'develop';
const head = 'master';

github.rest.pulls.create({
owner,
repo,
title,
body,
base,
head
});
Loading