-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
253 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Rust Create Hotfix PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Name of the support branch (e.g. `support/v1.2`)' | ||
required: true | ||
|
||
jobs: | ||
create-hotfix-pr: | ||
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 | ||
uses: iotaledger/identity.rs/.github/workflows/shared-create-hotfix-pr.yml@dev | ||
with: | ||
branch: ${{ github.event.inputs.branch }} | ||
branch-regex: ^support\/v[0-9]+\.[0-9]+$ | ||
tag-prefix: v | ||
main-tag-regex: ^v[0-9]+\.[0-9]+\.[0-9]+$ | ||
changelog-config-path: ./.github/.github_changelog_generator | ||
release-target: rust | ||
secrets: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# joins an array with a delimiter | ||
joinBy() { | ||
local IFS="$1"; shift; echo "$*"; | ||
} | ||
|
||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# takes a string and increments the last number | ||
# e.g. $(updateVersion 1.1.0) -> 1.1.1 | ||
# e.g. $(updateVersion 1.1.0-dev.1) -> 1.1.0-dev.2 | ||
|
||
[[ ${1} =~ ^(.*[^0-9])?([0-9]+)$ ]] && \ | ||
[[ ${#BASH_REMATCH[1]} -gt 0 ]] && \ | ||
printf "%s%0${#BASH_REMATCH[2]}d" "${BASH_REMATCH[1]}" "$((10#${BASH_REMATCH[2]} + 1 ))" || \ | ||
printf "%0${#BASH_REMATCH[2]}d" "$((10#${BASH_REMATCH[2]} + 1))" || \ | ||
printf "${1}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
name: Shared / Create Hotfix PR | ||
|
||
# This workflow creates a Pull Request meant for creating releases. | ||
# A changelog, including the new version, is generated and version strings in relevant files are replaced. | ||
# All these changes are committed and submitted as a Pull Request. | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch-regex: | ||
description: "regex to validate branch input against" | ||
required: true | ||
type: string | ||
branch: | ||
description: "branch to hotfix on" | ||
required: true | ||
type: string | ||
tag-prefix: | ||
description: "will be pre-pended to tag-base" | ||
required: false | ||
type: string | ||
main-tag-regex: | ||
description: "the regex to find all related main releases" | ||
required: true | ||
type: string | ||
changelog-path: | ||
description: "path to the changelog file" | ||
required: false | ||
default: ./CHANGELOG.md | ||
type: string | ||
changelog-config-path: | ||
description: "path to the changelog config" | ||
required: true | ||
type: string | ||
pr-body-text: | ||
description: "text to be included in the PR" | ||
required: false | ||
type: string | ||
release-target: | ||
description: "target of the release (rust|wasm)" | ||
required: true | ||
type: string | ||
secrets: | ||
GPG_PRIVATE_KEY: | ||
description: "GPG private key for signing commits and tags" | ||
required: true | ||
GPG_PASSPHRASE: | ||
description: "GPG private passphrase for signing commits and tags" | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Validate branch | ||
run: | | ||
if ! [[ ${{ inputs.branch }} =~ ${{ inputs.branch-regex }} ]]; then | ||
echo unrecognized branch ${{ inputs.branch }}, must match ${{ inputs.branch-regex }} | ||
exit 1 | ||
fi | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
# Number of commits to fetch. 0 indicates all history for all branches and tags. | ||
fetch-depth: 0 | ||
ref: ${{ inputs.branch }} | ||
|
||
- name: Determine Hotfix Version | ||
run: | | ||
TAG_PREFIX=${{ inputs.tag-prefix }} | ||
BRANCHNAME=${{ inputs.branch }} | ||
SUPPORT_TAG_BASE=${BRANCHNAME##*/} | ||
ALL_TAGS=$(git tag --sort=-version:refname -l) | ||
temp_array=() | ||
for value in ${ALL_TAGS[@]} | ||
do | ||
# consider tags matching the RegEx for main tags and matching the support branch base | ||
if [[ $value =~ ${{ inputs.main-tag-regex }} && $value == $SUPPORT_TAG_BASE* ]]; then | ||
LATEST_TAG=$value | ||
break | ||
fi | ||
done | ||
unset temp_array | ||
echo LATEST_TAG=$LATEST_TAG | ||
HOTFIX_TAG=$(.github/workflows/scripts/updateVersion.sh $LATEST_TAG) | ||
echo HOTFIX_TAG=$HOTFIX_TAG | ||
echo HOTFIX_TAG=$HOTFIX_TAG >> $GITHUB_ENV | ||
HOTFIX_VERSION=$(echo "$HOTFIX_TAG" | sed "s/$TAG_PREFIX*//") | ||
echo HOTFIX_VERSION=$HOTFIX_VERSION | ||
echo HOTFIX_VERSION=$HOTFIX_VERSION >> $GITHUB_ENV | ||
- name: Determine Excluded Tags | ||
run: | | ||
# create a list of tags that are unrelated to the current release | ||
ALL_TAGS=$(git tag -l) | ||
temp_array=() | ||
for value in ${ALL_TAGS[@]} | ||
do | ||
if ! [[ $value =~ ${{ inputs.main-tag-regex }} && $(git branch -a --contains $value | grep ${{ inputs.branch }}) ]]; then | ||
temp_array+=($value) | ||
fi | ||
done | ||
UNRELATED_TAGS=$(.github/workflows/scripts/array.sh joinBy , "${temp_array[@]}") | ||
unset temp_array | ||
echo UNRELATED_TAGS=$UNRELATED_TAGS | ||
# set variables | ||
FIRST="--exclude-tags " | ||
SECOND=$UNRELATED_TAGS | ||
EXCLUDE_ARG=$FIRST$SECOND | ||
echo EXCLUDE_ARG=$EXCLUDE_ARG | ||
echo EXCLUDE_ARG=$EXCLUDE_ARG >> $GITHUB_ENV | ||
- name: Run Changelog Generator | ||
uses: './.github/actions/release/changelog-generator' | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
changelog-path: ${{ inputs.changelog-path }} | ||
changelog-config-path: ${{ inputs.changelog-config-path }} | ||
future-release: ${{ env.HOTFIX_TAG }} | ||
optional-arg: ${{env.EXCLUDE_ARG}} | ||
|
||
- name: Check Changelog For Modification | ||
run: | | ||
git add . | ||
if [[ $(git diff --stat --staged) == '' ]]; then | ||
echo 'repository unmodified' | ||
exit 1 | ||
fi | ||
- name: Import GPG key | ||
id: import-gpg | ||
uses: crazy-max/ghaction-import-gpg@cb4264d3319acaa2bea23d51ef67f80b4f775013 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.GPG_PASSPHRASE }} | ||
git_user_signingkey: true | ||
git_commit_gpgsign: true | ||
git_tag_gpgsign: true | ||
|
||
- name: Bump Versions | ||
uses: './.github/actions/release/bump-versions' | ||
with: | ||
release-target: ${{inputs.release-target}} | ||
version: ${{ env.HOTFIX_VERSION }} | ||
|
||
- name: Commit changes | ||
run: | | ||
git add . | ||
if [[ $(git diff --stat --staged) == '' ]]; then | ||
echo 'repository unmodified' | ||
exit 1 | ||
fi | ||
git commit -m "changelog and versions" | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@67df31e08a133c6a77008b89689677067fef169e | ||
with: | ||
committer: GitHub <[email protected]> | ||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
branch: hotfix/${{ env.HOTFIX_TAG }} | ||
delete-branch: true | ||
title: 'Hotfix ${{ env.HOTFIX_TAG }}' | ||
body: | | ||
This automatically generated PR contains changes for the `${{ env.HOTFIX_TAG }}` hotfix. | ||
${{inputs.pr-body-text}} | ||
If you discover any mistakes fix them with commits on this branch. If you want to abort the hotfix simply close the PR. | ||
labels: | | ||
No changelog | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Wasm Create Hotfix PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Name of the support branch (e.g. `support/wasm-v1.2`)' | ||
required: true | ||
|
||
jobs: | ||
create-hotfix-pr: | ||
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 | ||
uses: iotaledger/identity.rs/.github/workflows/shared-create-hotfix-pr.yml@dev | ||
with: | ||
branch: ${{ github.event.inputs.branch }} | ||
branch-regex: ^support\/wasm-v[0-9]+\.[0-9]+$ | ||
tag-prefix: wasm-v | ||
main-tag-regex: ^wasm-v[0-9]+\.[0-9]+\.[0-9]+$ | ||
changelog-config-path: ./bindings/wasm/.github_changelog_generator | ||
changelog-path: ./bindings/wasm/CHANGELOG.md | ||
release-target: wasm | ||
secrets: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |