-
Notifications
You must be signed in to change notification settings - Fork 5
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
4 changed files
with
64 additions
and
48 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,47 @@ | ||
name: Release | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: master | ||
token: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
|
||
- name: Fetch next version | ||
run: | | ||
echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV | ||
- name: Check if release is necessary | ||
id: release_guard | ||
run: | | ||
if git tag | grep -q "^${VERSION}$"; then | ||
echo "do_release=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "do_release=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Apply release changes | ||
if: steps.release_guard.outputs.do_release == 'true' | ||
run: | | ||
./release.sh $VERSION | ||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: master | ||
skip_checkout: true | ||
commit_message: Release ${{ env.VERSION }} | ||
|
||
- name: Generate release notes | ||
if: steps.release_guard.outputs.do_release == 'true' | ||
env: | ||
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} | ||
run: gh release create "$VERSION" --generate-notes -t "$VERSION" |
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 |
---|---|---|
@@ -1,54 +1,26 @@ | ||
#!/bin/bash -e | ||
#!/bin/bash | ||
set -e | ||
|
||
if ! command -v gh &> /dev/null | ||
then | ||
echo "gh command should be available for running this script" | ||
echo "see https://github.com/cli/cli/" | ||
exit 1 | ||
if [ -z "$GITHUB_WORKSPACE" ]; then | ||
echo "You should not run anymore this script from your machine, see updated README" | ||
exit 1 | ||
fi | ||
|
||
gh auth status | ||
|
||
if [ -z "$1" ] || [[ ! "$1" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
echo 'First argument should be next version to release with a leading v char' | ||
exit 1 | ||
fi | ||
|
||
echo "This script will switch to master and pull origin/master to make sure you are in sync" | ||
read -p "Are you sure? " -n 1 -r | ||
echo | ||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
exit 1 | ||
echo 'First argument should be next version to release with a leading v char' | ||
exit 1 | ||
fi | ||
|
||
git fetch | ||
git checkout master | ||
git pull origin master --no-rebase | ||
|
||
CURRENT_VERSION=$(git tag | sort -r --version-sort | head -n1) | ||
echo "Current version is $CURRENT_VERSION" | ||
echo "Going to create a PR to release $1" | ||
|
||
git checkout -b "$1" | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
grep -Rl "Alfresco/alfresco-build-tools.*@$CURRENT_VERSION" | xargs sed -i '' -e "s/\(Alfresco\/alfresco-build-tools.*@\)$CURRENT_VERSION/\1$1/g" | ||
sed -i '' -e "s/$CURRENT_VERSION/$1/" .pre-commit-config.yaml | ||
else | ||
grep -Rl "Alfresco/alfresco-build-tools.*@$CURRENT_VERSION" | xargs sed -i -e "s/\(Alfresco\/alfresco-build-tools.*@\)$CURRENT_VERSION/\1$1/g" | ||
sed -i -e "s/$CURRENT_VERSION/$1/" .pre-commit-config.yaml | ||
if [ -z "$CURRENT_VERSION" ]; then | ||
echo "Can't retrieve tags" | ||
exit 1 | ||
fi | ||
|
||
grep -Rl "$1" | xargs git add | ||
|
||
git commit -m "Prepare to release $1" | ||
git push origin "$1" | ||
echo "Current version is $CURRENT_VERSION" | ||
echo "Going to flip refs to $1" | ||
|
||
gh pr create -a '@me' -t "Release $1" -b '' | ||
git checkout master | ||
grep -Rl "Alfresco/alfresco-build-tools.*@$CURRENT_VERSION" | xargs sed -i -e "s/\(Alfresco\/alfresco-build-tools.*@\)$CURRENT_VERSION/\1$1/g" | ||
sed -i -e "s/$CURRENT_VERSION/$1/" .pre-commit-config.yaml | ||
|
||
echo "" | ||
echo "Once PR is merged execute locally:" | ||
echo "- git pull origin master" | ||
echo "- gh release create $1 --generate-notes -t $1" | ||
echo "" | ||
echo "Rename completed succesfully" |
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 @@ | ||
v2.8.0 |