Skip to content

Commit

Permalink
Apply semver
Browse files Browse the repository at this point in the history
  • Loading branch information
stleamist committed Dec 8, 2020
1 parent c440b7b commit 4c4add6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/fetch-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4c4add6

Please sign in to comment.