Skip to content

Commit

Permalink
Merge pull request #7 from tawanda-kembo/feat/automate-versioning
Browse files Browse the repository at this point in the history
Feat/automate versioning
  • Loading branch information
tawandakembo authored Jul 27, 2024
2 parents 0255734 + 1e3a1fb commit 5115798
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Bump version and push tag
env:
DEFAULT_BUMP: minor
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./bump_version.sh

- name: Create Release
Expand All @@ -41,4 +41,4 @@ jobs:
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 6 additions & 11 deletions bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,21 @@ esac

NEW_VERSION="$MAJOR.$MINOR.$PATCH"

# Configure git to use the PAT
# Configure git to use the GITHUB_TOKEN
git config --global user.name "github-actions"
git config --global user.email "[email protected]"

# Debug information
echo "Setting remote URL with PAT_TOKEN"
echo "PAT_TOKEN: ${#PAT_TOKEN}"

# Set the remote URL with the PAT
git remote set-url origin "https://${PAT_TOKEN}@github.com/tawanda-kembo/code-collator.git"
# Set the remote URL with the GITHUB_TOKEN
git remote set-url origin "https://${GITHUB_TOKEN}@github.com/tawanda-kembo/code-collator.git"

# Create a new tag
git tag "v$NEW_VERSION"

# Push the tag using the PAT
# Push the tag using the GITHUB_TOKEN
GIT_ASKPASS=$(mktemp)
echo "echo \$PAT_TOKEN" > $GIT_ASKPASS
echo "echo \$GITHUB_TOKEN" > $GIT_ASKPASS
chmod +x $GIT_ASKPASS

GIT_HTTP_USER_AGENT="git/2.29.0" GIT_ASKPASS=$GIT_ASKPASS git push origin "v$NEW_VERSION"
GIT_ASKPASS=$GIT_ASKPASS git push origin "v$NEW_VERSION"

# Clean up
rm $GIT_ASKPASS

0 comments on commit 5115798

Please sign in to comment.