fix: update deps #321
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
name: test | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
test: | ||
name: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.21" | ||
- name: Run Tests | ||
id: go_test | ||
run: go test -v ./... | ||
# Conditional step: Create a new tag if tests pass | ||
- name: Bump Version and Create Tag | ||
if: ${{ success() && steps.go_test.outcome == 'success' }} | ||
id: versioning | ||
env: | ||
TAG_CREATION_TOKEN: ${{ secrets.OG_RELEASE_TAG_UPDATE }} | ||
run: | | ||
# Configure git with the token to allow tag creation | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git fetch --tags | ||
# Get the latest tag and increment based on semantic versioning rules | ||
latest_tag=$(git tag --sort=-v:refname | head -n 1) | ||
if [ -z "$latest_tag" ]; then | ||
# If no tags exist, start at v0.1.0 | ||
new_tag="v0.1.0" | ||
else | ||
# Split the latest tag into major, minor, and patch | ||
IFS='.' read -r major minor patch <<< "${latest_tag//v/}" | ||
# Increment the patch version | ||
patch=$((patch + 1)) | ||
new_tag="v${major}.${minor}.${patch}" | ||
fi | ||
# Create and push the new tag | ||
git tag "$new_tag" | ||
git push https://${{ secrets.OG_RELEASE_TAG_UPDATE }}@github.com/opengovern/og-util "$new_tag" | ||
# Output the new tag | ||
- name: Display new tag | ||
if: ${{ success() && steps.versioning.outcome == 'success' }} | ||
run: echo "Created new tag: ${{ steps.versioning.outputs.new_tag }}" | ||