From 4c4add6e954c6571ef95ae757e1265ec51b889b0 Mon Sep 17 00:00:00 2001 From: Dongkyu Kim Date: Tue, 8 Dec 2020 20:56:31 +0900 Subject: [PATCH] Apply semver --- .github/workflows/create-releases.yml | 32 +++++++++++++++++++++++---- .github/workflows/fetch-releases.yml | 15 +++++++++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml index ff3e119..a96a0cc 100644 --- a/.github/workflows/create-releases.yml +++ b/.github/workflows/create-releases.yml @@ -4,6 +4,7 @@ on: workflow_dispatch: inputs: tags: + # TODO: [{ srcTag: "release/3.0.0", destTag: "v3.0.0" }] 형태로 받아보기 description: 'Tags (JSON)' required: true default: '["release/1.0.0"]' @@ -12,6 +13,16 @@ env: upstream_repo_full_name: 'navermaps/NMapsMap' git_config_user_name: 'github-actions' git_config_user_email: '41898282+github-actions[bot]@users.noreply.github.com' + function_semver: | + function(tag) { + try { + const regExp = /\d*\.\d*\.\d*.*/; + const prefix = "v"; + return prefix + regExp.exec(tag)[0]; + } catch { + return tag; + } + } # TODO: Assertion 추가하기 jobs: @@ -74,10 +85,23 @@ jobs: - name: Create a ZIP archive working-directory: binaries run: zip -r -X NMapsMap.xcframework.zip NMapsMap.xcframework + + # TODO: 이름 다듬기 + # TODO: env 또는 output 일원화하기 + - name: semver + id: semver + uses: actions/github-script@v3 + with: + script: | + const semver = ${{ env.function_semver }}; + const tag = '${{ matrix.tag }}'; + const semveredTag = semver(tag); + core.setOutput("semveredTag", semveredTag); + console.log("semveredTag: ", semveredTag); - name: Estimate an asset URL run: | - url=https://github.com/${{ github.repository }}/releases/download/${{ matrix.tag }}/NMapsMap.xcframework.zip + url=https://github.com/${{ github.repository }}/releases/download/${{ steps.semver.outputs.semveredTag }}/NMapsMap.xcframework.zip echo "url=$url" >> $GITHUB_ENV echo $url @@ -111,8 +135,8 @@ jobs: # TODO: Pull run: | git add -A - git commit -m "Bump to ${{ matrix.tag }}" - git tag ${{ matrix.tag }} + git commit -m "Bump to ${{ steps.semver.outputs.semveredTag }}" + git tag ${{ steps.semver.outputs.semveredTag }} git pull --rebase git push origin HEAD git push --tags origin HEAD @@ -123,7 +147,7 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} with: - tag_name: ${{ matrix.tag }} + tag_name: ${{ steps.semver.outputs.semveredTag }} - name: Upload a release asset id: upload_release_asset diff --git a/.github/workflows/fetch-releases.yml b/.github/workflows/fetch-releases.yml index 419d77c..5415a3d 100644 --- a/.github/workflows/fetch-releases.yml +++ b/.github/workflows/fetch-releases.yml @@ -8,6 +8,16 @@ on: env: upstream_repo_owner: 'navermaps' upstream_repo_name: 'NMapsMap' + function_semver: | + function(tag) { + try { + const regExp = /\d*\.\d*\.\d*.*/; + const prefix = "v"; + return prefix + regExp.exec(tag)[0]; + } catch { + return tag; + } + } jobs: check_pat: @@ -68,10 +78,11 @@ jobs: uses: actions/github-script@v3 with: script: | + const semver = ${{ env.function_semver }}; const workingRepoTags = ${{ steps.list_tags_working.outputs.workingRepoTags }}; const upstreamRepoTags = ${{ steps.list_tags_upstream.outputs.upstreamRepoTags }}; - const removedTags = workingRepoTags.filter(tag => !upstreamRepoTags.includes(tag)); - const addedTags = upstreamRepoTags.filter(tag => !workingRepoTags.includes(tag)); + const removedTags = workingRepoTags.filter(tag => !upstreamRepoTags.map(semver).includes(tag)); + const addedTags = upstreamRepoTags.filter(tag => !workingRepoTags.includes(semver(tag))); core.setOutput("removedTags", removedTags); core.setOutput("addedTags", addedTags); console.log("removedTags: ", removedTags);