Skip to content

Commit

Permalink
213
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Sep 27, 2024
1 parent 59c6813 commit 4eac857
Showing 1 changed file with 63 additions and 63 deletions.
126 changes: 63 additions & 63 deletions .github/workflows/change-release.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
name: Update Version and Tag

on:
release:
types: [created]
release:
types: [created]

jobs:
update-version:
if: startsWith(github.event.release.tag_name, 'v') && contains(github.event.release.tag_name, '.')
runs-on: ubuntu-latest
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
BRANCH_NAME: update-tag-version-${{ github.event.release.tag_name }}
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# Step 2: Set up Git with official account
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Step 3: Update version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > version/version
# Step 4: Commit and push changes
- name: Commit and push changes
update-version:
if: startsWith(github.event.release.tag_name, 'v') && contains(github.event.release.tag_name, '.')
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin HEAD:${{ github.ref }}
# Step 5: Check if tag exists and delete if it does
- name: Check and delete existing tag
run: |
if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then
git tag -d ${{ env.TAG_VERSION }}
git push --delete origin ${{ env.TAG_VERSION }}
fi
# Step 6: Create and push tag
- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ env.TAG_VERSION }}
git push origin ${{ env.TAG_VERSION }}
# Step 7: Publish the release
- name: Publish Release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const release_id = context.payload.release.id;
await github.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
draft: false
});
TAG_VERSION: ${{ github.event.release.tag_name }}
BRANCH_NAME: update-tag-version-${{ github.event.release.tag_name }}
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# Step 2: Set up Git with official account
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Step 3: Update version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > version/version
# Step 4: Commit and push changes
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin HEAD:${{ github.ref }}
# Step 5: Check if tag exists and delete if it does
- name: Check and delete existing tag
run: |
if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then
git tag -d ${{ env.TAG_VERSION }}
git push --delete origin ${{ env.TAG_VERSION }}
fi
# Step 6: Create and push tag
- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ env.TAG_VERSION }}
git push origin ${{ env.TAG_VERSION }}
# Step 7: Publish the release
- name: Publish Release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const release_id = context.payload.release.id;
await github.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
draft: false
});

0 comments on commit 4eac857

Please sign in to comment.