1- # TODO get inspiration by https://github.com/formium/formik/blob/master/.github/workflows/release.yml
2- # https://www.christopherbiscardi.com/post/shipping-multipackage-repos-with-github-actions-changesets-and-lerna
3-
4- name : release
1+ name : Release
52on :
6- pull_request :
7- branches :
8- - master
9- types : [closed]
3+ push :
4+ branches : [master]
105
116jobs :
12- publish :
13- name : Publish
14- runs-on : ubuntu-18.04
7+ release :
8+ name : Release
9+ runs-on : ubuntu-latest
1510 steps :
16-
17- # Checkout Project
11+ # Checkout Project
1812 - name : 📚 Checkout
1913 uses : actions/checkout@v2
2014
@@ -28,79 +22,13 @@ jobs:
2822 - name : ⏳ Install
2923 run : yarn install
3024
31- # Configure Git User so that it can perform Git Actions like commits
32- - name : 👷 Configure Git User
33- run : |
34- git config --global user.name 'bennodev19'
35- git config --global user.email 'bennodev19@users.noreply.github.com'
36- env :
37- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38-
39- # Define ${CURRENT_VERSION}
40- - name : 🔑 Set Current Version
41- shell : bash -ex {0}
42- run : |
43- CURRENT_VERSION=$(node -p 'require("./lerna.json").version')
44- echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
45-
46- # Check if Tag with the CURRENT_VERSION already exists
47- - name : Tag Check
48- id : tag-check
49- shell : bash -ex {0}
50- run : |
51- GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}"
52- http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
53- -H "Authorization: token ${GITHUB_TOKEN}")
54- if [ "$http_status_code" -ne "404" ] ; then
55- echo "::set-output name=exists_tag::true"
56- else
57- echo "::set-output name=exists_tag::false"
58- fi
59- env :
60- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61-
62- # Create Git Tag if Tag doesn't already exists
63- - name : 🏷 Create Git Tag
64- if : steps.tag-check.outputs.exists_tag == 'false'
65- uses : azu/action-package-version-to-git-tag@v1
25+ # Create Release Pull Request
26+ - name : 📤 Create Release Pull Request or Publish to NPM
27+ uses : changesets/action@master
6628 with :
67- version : ${{ env.CURRENT_VERSION }}
68- github_token : ${{ secrets.GITHUB_TOKEN }}
69- github_repo : ${{ github.repository }}
70- git_commit_sha : ${{ github.sha }}
71- git_tag_prefix : " v"
72-
73- # Create Release
74- - name : 📝 Create Release
75- id : create-release
76- if : steps.tag-check.outputs.exists_tag == 'false' && github.event.pull_request.merged == true
77- uses : actions/create-release@v1
29+ publish : yarn release
30+ commit : Version Release
31+ title : Next Release
7832 env :
7933 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80- with :
81- tag_name : v${{ env.CURRENT_VERSION }}
82- # Copy Pull Request's tile and body to Release Note
83- release_name : ${{ github.event.pull_request.title }}
84- body : |
85- ${{ github.event.pull_request.body }}
86- draft : false
87- prerelease : false
88-
89- # Publish
90- - name : 🚀 Publish
91- if : steps.tag-check.outputs.exists_tag == 'false'
92- run : |
93- yarn lerna publish from-package --yes
94- env :
95- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
96- NODE_AUTH_TOKEN : ${{ secrets.NPM_AUTH_TOKEN }}
97- - uses : actions/github-script@0.8.0
98- with :
99- github-token : ${{secrets.GITHUB_TOKEN}}
100- script : |
101- github.issues.createComment({
102- issue_number: context.issue.number,
103- owner: context.repo.owner,
104- repo: context.repo.repo,
105- body: 'https://github.com/${{ github.repository }}/releases/tag/v${{ env.CURRENT_VERSION }} is released 🎉'
106- })
34+ NPM_TOKEN : ${{ secrets.NPM_AUTH_TOKEN }}
0 commit comments