Skip to content

Commit

Permalink
add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingshuke committed May 22, 2024
1 parent 61866f6 commit d0d90b6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 18 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/android_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,4 @@ jobs:
tag_name: ${{ env.VERSION }}
token: ${{ secrets.RELEASE_TOKEN }}
files: |
build/app/outputs/flutter-apk/app-release.apk
# Note: the original tag that triggered the workflow is in the form vX.Y.Z
# but the pubspec.yaml is committed in the commit after that one.
# Since we need the tag to point to the correct commit for other workflows
# such as f-droid we need a way to correct it. Only moving the tag
# would not work, as it would trigger this workflow again. So as
# a workaround, we use the v-tag to trigger this workflow, add a new
# one without the v and push it.
- name: Commit pubspec version and delete tag
run: |
git config user.name Github-Actions
git config user.email [email protected]
git remote set-url origin https://${{ secrets.RELEASE_TOKEN }}@github.com/shukebeta/HappyNotes.git
git checkout -b release-${{ env.VERSION }}
git add pubspec.yaml
git commit -m "Bump version to $( flutter pub run cider version )"
git push origin --delete ${{ env.VERSION_V }}
git push --set-upstream origin release-${{ env.VERSION }}
build/app/outputs/flutter-apk/app-release.apk
53 changes: 53 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Check if the workspace is clean and on the master branch
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Your workspace has uncommitted changes. Please commit or stash them before continuing."
exit 1
fi

if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "Error: You are not on the master branch. Please switch to the master branch before continuing."
exit 1
fi

# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <version_tag> <release_note>"
echo "Example: $0 v1.2.3 \"This is a release note\""
exit 1
fi

# Check if the version tag is in the correct format
VERSION_TAG=$1
if ! [[ $VERSION_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version tag format. It should be in the format 'v[number].[number].[number]'."
exit 1
fi

RELEASE_NOTE=$2

# Extract the version number from the tag
VERSION=${VERSION_TAG:1}

# Pull the latest changes from the remote repository
git pull --ff-only origin master

# Set the version number in pubspec.yaml
sed -i '' "s/^version: .*$/version: $VERSION/" pubspec.yaml

# Add all changes to Git
git add pubspec.yaml

# Commit the changes with a message
git commit -m "Release version $VERSION"

# Create a Git tag with the release note
git tag -a "$VERSION_TAG" -m "$RELEASE_NOTE"

# Push the changes and the new tag to the remote repository
git push origin master
git push origin "$VERSION_TAG"

echo "Release process completed successfully for version $VERSION (tag: $VERSION_TAG)"
echo "Changes and the new tag have been pushed to the remote repository."

0 comments on commit d0d90b6

Please sign in to comment.