From df7729006f093dad1d3733e2e610277ebb613ad5 Mon Sep 17 00:00:00 2001 From: Masoud Amjadi Date: Tue, 5 Sep 2023 21:18:56 -0400 Subject: [PATCH] fix(test): test github release --- .github/workflows/gh-release-test.yml | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/gh-release-test.yml diff --git a/.github/workflows/gh-release-test.yml b/.github/workflows/gh-release-test.yml new file mode 100644 index 000000000..c089fb37c --- /dev/null +++ b/.github/workflows/gh-release-test.yml @@ -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