Skip to content

Commit

Permalink
refactor: update release workflow to allow write permissions and enha…
Browse files Browse the repository at this point in the history
…nce versioning logic
  • Loading branch information
carolinebrasil committed Dec 7, 2024
1 parent 933b9c9 commit 9f7d394
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
GITHUB_OUTPUT: $GITHUB_ENV

permissions:
contents: read
contents: write

jobs:
release:
Expand All @@ -37,9 +37,15 @@ jobs:
patch_regex: "(?i)^(.+:)?(hotfix/.+)"
debug: "true"

- name: Debug SemVer
run: |
echo "New version: ${{ steps.semver-tag.outputs.semver_tag }}"
echo "Git SHA: ${{ github.sha }}"
- name: Create git tag
uses: rickstaa/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.semver-tag.outputs.semver_tag }}

- name: Configure AWS credentials
Expand Down Expand Up @@ -70,9 +76,13 @@ jobs:
env:
NEW_VERSION: ${{ steps.semver-tag.outputs.semver_tag }}
run: |
sed -i "1i ## [${{ env.NEW_VERSION }}] - $(date +'%d-%m-%Y')\n\n### Added\n" CHANGELOG.md
echo $NEW_VERSION > VERSION
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
if ! grep -q "\[${{ env.NEW_VERSION }}\]" CHANGELOG.md; then
sed -i "1i ## [${{ env.NEW_VERSION }}] - $(date +'%d-%m-%Y')\n\n### Added\n" CHANGELOG.md
echo $NEW_VERSION > VERSION
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
else
echo "Version $NEW_VERSION already exists in CHANGELOG.md. Skipping update."
fi
- name: Commit and push updated version in CHANGELOG.md
env:
Expand Down Expand Up @@ -106,4 +116,4 @@ jobs:
cd $KUSTOMIZE_DIR
echo "Using image version: ${{ env.NEW_VERSION }}"
kubectl apply -k $KUSTOMIZE_DIR -n $ENVIRONMENT && echo "Resources deployed successfully!" || (echo "Failed to deploy resources!" && exit 1)
kubectl apply -k $KUSTOMIZE_DIR -n $ENVIRONMENT && echo "Resources deployed successfully!" || {echo "Failed to deploy resources! Check the logs"; kubectl describe pods -n $ENVIRONMENT; exit 1; }

0 comments on commit 9f7d394

Please sign in to comment.