Skip to content

Commit

Permalink
workflow: modified
Browse files Browse the repository at this point in the history
  • Loading branch information
forkimenjeckayang committed Jun 12, 2024
1 parent 6204c55 commit ff83828
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Release
name: Create or Update Release

on:
push:
Expand All @@ -12,15 +12,34 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

# You may need additional setup steps depending on your project's needs
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse v1.0.0 >/dev/null 2>&1
then
echo "::set-output name=tag_exists::true"
else
echo "::set-output name=tag_exists::false"
fi
- name: Create Tag
if: steps.check_tag.outputs.tag_exists == 'false'
run: git tag v1.0.0 # Replace with your desired tag name

- name: Push Tag
run: git push --tags
if: steps.check_tag.outputs.tag_exists == 'false'
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git
git push --tags
- name: Create Release
- name: Create or Update Release
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -32,4 +51,13 @@ jobs:
Release notes for v1.0.0
- Feature 1 implemented
- Bug fixes
continue-on-error: true

- name: Update Existing Release
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_ID=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/v1.0.0 | jq -r '.id')
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID \
-d '{"tag_name": "v1.0.0", "name": "Release v1.0.0", "body": "Release notes for v1.0.0\n- Feature 1 implemented\n- Bug fixes"}'

0 comments on commit ff83828

Please sign in to comment.