Skip to content

Commit

Permalink
fix(test): test github release
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudmanson committed Sep 6, 2023
1 parent d31aa9d commit df77290
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/gh-release-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Version Check and Tag

on:
push:
branches:
- "*"

jobs:
version_check_and_tag:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository code
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Current Versions
id: set_versions
run: |
CURRENT_VERSIONS=""
for package_json in $(find ./packages -name package.json); do
version=$(jq -r .version $package_json)
CURRENT_VERSIONS="${CURRENT_VERSIONS}${version},"
done
CURRENT_VERSIONS=${CURRENT_VERSIONS%,} # Remove trailing comma
echo "CURRENT_VERSIONS=${CURRENT_VERSIONS}" >> $GITHUB_ENV
- name: Tag Check
id: tag_check
run: |
for version in $(echo $CURRENT_VERSIONS | tr ',' ' '); do
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${version}"
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
-H "Authorization: token ${GITHUB_TOKEN}")
if [ "$http_status_code" -ne "404" ] ; then
echo "::set-output name=exists_tag::true"
else
echo "::set-output name=exists_tag::false"
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Git Tags
if: steps.tag_check.outputs.exists_tag == 'true'
run: |
for version in $(echo $CURRENT_VERSIONS | tr ',' ' '); do
echo $version
done
# - name: Create Release
# id: create_release
# if: steps.tag_check.outputs.exists_tag == 'true'
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ env.CURRENT_VERSIONS }}
# # Copy Pull Request's title and body to Release Note
# release_name: ${{ github.event.pull_request.title }}
# body: |
# ${{ github.event.pull_request.body }}
# draft: false
# prerelease: false

0 comments on commit df77290

Please sign in to comment.