-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deleted the workflow added incorrectly to the .github folder. Added new workflow file to perform the version update steps when a new release is created Signed-off-by: Chaminda Divitotawela <[email protected]>
- Loading branch information
1 parent
4d4131b
commit ac52fc9
Showing
3 changed files
with
98 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
# | ||
# Besu Docs new Besu version update helper | ||
# | ||
|
||
log_error() { | ||
echo "ERROR: $1" | ||
exit 1 | ||
} | ||
|
||
# Validate the environment variables set | ||
[[ -z "$VERSION" ]] && log_error "Environment variable VERSION cannot be empty" | ||
|
||
FILE="${FILE:-docusaurus.config.js}" | ||
GIT_NAME="${GIT_NAME:-Besu Bot}" | ||
GIT_EMAIL="${GIT_EMAIL:-devops@consensys.net}" | ||
BASE_BRANCH="${BASE_BRANCH:-main}" | ||
BRANCH="besu-version-$VERSION" | ||
|
||
# Configure git | ||
git config --global user.name "$GIT_NAME" | ||
git config --global user.email "$GIT_EMAIL" | ||
|
||
# Create branch | ||
git checkout -b "$BRANCH" | ||
|
||
# https://docs-template.consensys.io/configure/versioning#create-a-docs-version | ||
yarn install | ||
npm run docusaurus docs:version "$VERSION" > /dev/null | ||
git add "versioned_docs/version-$VERSION/" | ||
git add "versioned_sidebars/version-$VERSION-sidebars.json" | ||
|
||
git add versions.json | ||
|
||
# Remove stable mark from the existing version | ||
sed -i 's/label\: "stable (\([0-9]*\.[0-9]*\.[0-9]*\))"/label: "\1"/' "$FILE" | ||
|
||
# Add new release as stable version | ||
sed -i "/\/\/ STABLE-AUTOMATION-TOKEN/a \ \"$VERSION\": {\n\ label: \"stable ($VERSION)\",\n\ }," "$FILE" | ||
|
||
# Update the latest version | ||
sed -i "s/lastVersion: \"[0-9]*\.[0-9]*\.[0-9]*\"/lastVersion: \"$VERSION\"/" "$FILE" | ||
|
||
# Output the diff | ||
git diff "$FILE" | ||
git diff versions.json | ||
|
||
# Commit and push branch | ||
git add "$FILE" | ||
git commit -s -m "Update version $VERSION" | ||
git push origin "$BRANCH" | ||
|
||
# Output Git status to see any unexpected file changes. These could be due to changes in the process | ||
echo "===== Git status after commit =====" | ||
git status -s | ||
echo "===================================" | ||
|
||
# Attempt to create PR. If no permission skip the PR creation | ||
echo "Attempt to create PR using base branch $BASE_BRANCH" | ||
gh pr create --base "$BASE_BRANCH" --title "Update Besu version $VERSION" --body "Besu version updated to $VERSION" || { | ||
echo "WRAN: Action does not have permission to create PRs. Ignoring..." | ||
} |
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
name: Update Version | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Check release name | ||
id: version | ||
run: | | ||
# User can input anything so check what is provided as release name | ||
echo "${{ github.event.release.name }}" | grep -q -e "^[0-9]*\.[0-9]*\.[0-9]*$" || { | ||
echo "Release name [$RELEASE_NAME] is not in expected format '^[0-9]*\.[0-9]*\.[0-9]*$'" | ||
exit 1 | ||
} | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
|
||
- name: Update version | ||
run: .github/scripts/update-version.sh | ||
env: | ||
VERSION: ${{ github.event.release.name }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |