diff --git a/.github/workflows/android_release.yml b/.github/workflows/android_release.yml index 40b4225..0144475 100644 --- a/.github/workflows/android_release.yml +++ b/.github/workflows/android_release.yml @@ -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 github-actions@github.com - 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 }} \ No newline at end of file + build/app/outputs/flutter-apk/app-release.apk \ No newline at end of file diff --git a/bin/release b/bin/release new file mode 100755 index 0000000..d262ee3 --- /dev/null +++ b/bin/release @@ -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 " + 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." \ No newline at end of file