-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d31aa9d
commit df77290
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
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 |