1- # TODO decide weather using changesets or doing it on your own
2-
31name : release
42on :
5- push :
3+ pull_request :
64 branches :
75 - master
6+ types : [closed]
87
98jobs :
10- release :
11- name : Release
9+ publish :
10+ name : Publish
1211 runs-on : ubuntu-latest
1312 steps :
1413
15- # Checkout Project
14+ # Checkout Project
1615 - name : 📚 Checkout
1716 uses : actions/checkout@v2
1817
@@ -23,116 +22,82 @@ jobs:
2322 node-version : 12
2423
2524 # Install Dependencies
26- - name : ⏳ Install Dependencies
25+ - name : ⏳ Install
2726 run : yarn install
2827
29- # Creates Release Pull Request with help of 'Changesets'
30- - name : 🚀 Create Release Pull Request
31- uses : changesets/action@master
28+ # Configure Git User so that it can perform Git Actions like commits
29+ - name : 👷 Configure Git User
30+ run : |
31+ git config --global user.name 'bennodev19'
32+ git config --global user.email 'bennodev19@users.noreply.github.com'
3233 env :
3334 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3435
35- # -- OLD --
36- #
37- # name: release
38- # on:
39- # pull_request:
40- # branches:
41- # - master
42- #
43- # jobs:
44- # publish:
45- # name: Publish
46- # runs-on: ubuntu-latest
47- # steps:
48-
49- # # Checkout Project
50- # - name: 📚 Checkout
51- # uses: actions/checkout@v2
52-
53- # # Setup NodeJS
54- # - name: 🟢 Setup Node ${{ matrix.node_version }}
55- # uses: actions/setup-node@v1
56- # with:
57- # node-version: 12
58-
59- # # Install Dependencies
60- # - name: ⏳ Install Dependencies
61- # run: yarn install
62-
63- # # Configure Git User so that it can perform Git Actions like commits
64- # - name: 👷 Configure Git User
65- # run: |
66- # git config --global user.name 'bennodev19'
67- # git config --global user.email 'bennodev19@users.noreply.github.com'
68- # env:
69- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
71- # # Define ${CURRENT_VERSION}
72- # - name: 🔑 Set Current Version
73- # shell: bash -ex {0}
74- # run: |
75- # CURRENT_VERSION=$(node -p 'require("./lerna.json").version')
76- # echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
77-
78- # # Check if Tag with the CURRENT_VERSION already exists
79- # - name: Tag Check
80- # id: tag-check
81- # shell: bash -ex {0}
82- # run: |
83- # GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}"
84- # http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
85- # -H "Authorization: token ${GITHUB_TOKEN}")
86- # if [ "$http_status_code" -ne "404" ] ; then
87- # echo "::set-output name=exists_tag::true"
88- # else
89- # echo "::set-output name=exists_tag::false"
90- # fi
91- # env:
92- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
94- # # Create Git Tag if Tag doesn't already exists
95- # - name: 🏷 Create Git Tag
96- # if: steps.tag-check.outputs.exists_tag == 'false'
97- # uses: azu/action-package-version-to-git-tag@v1
98- # with:
99- # version: ${{ env.CURRENT_VERSION }}
100- # github_token: ${{ secrets.GITHUB_TOKEN }}
101- # github_repo: ${{ github.repository }}
102- # git_commit_sha: ${{ github.sha }}
103- # git_tag_prefix: "v"
104-
105- # # Create Release
106- # - name: 📝 Create Release
107- # id: create-release
108- # if: steps.tag-check.outputs.exists_tag == 'false' && github.event.pull_request.merged == true
109- # uses: actions/create-release@v1
110- # env:
111- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112- # with:
113- # tag_name: v${{ env.CURRENT_VERSION }}
114- # # Copy Pull Request's tile and body to Release Note
115- # release_name: ${{ github.event.pull_request.title }}
116- # body: |
117- # ${{ github.event.pull_request.body }}
118- # draft: false
119- # prerelease: false
36+ # Define ${CURRENT_VERSION}
37+ - name : 🔑 Set Current Version
38+ shell : bash -ex {0}
39+ run : |
40+ CURRENT_VERSION=$(node -p 'require("./lerna.json").version')
41+ echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
42+
43+ # Check if Tag with the CURRENT_VERSION already exists
44+ - name : Tag Check
45+ id : tag-check
46+ shell : bash -ex {0}
47+ run : |
48+ GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}"
49+ http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
50+ -H "Authorization: token ${GITHUB_TOKEN}")
51+ if [ "$http_status_code" -ne "404" ] ; then
52+ echo "::set-output name=exists_tag::true"
53+ else
54+ echo "::set-output name=exists_tag::false"
55+ fi
56+ env :
57+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
12058
121- # # Publish
122- # - name: 🚀 Publish
123- # if: steps.tag-check.outputs.exists_tag == 'false'
124- # run: |
125- # yarn lerna publish from-package --yes
126- # env:
127- # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128- # NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
129- # - uses: actions/github-script@0.8.0
130- # with:
131- # github-token: ${{secrets.GITHUB_TOKEN}}
132- # script: |
133- # github.issues.createComment({
134- # issue_number: context.issue.number,
135- # owner: context.repo.owner,
136- # repo: context.repo.repo,
137- # body: 'https://github.com/${{ github.repository }}/releases/tag/v${{ env.CURRENT_VERSION }} is released 🎉'
138- # })
59+ # Create Git Tag if Tag doesn't already exists
60+ - name : 🏷 Create Git Tag
61+ if : steps.tag-check.outputs.exists_tag == 'false'
62+ uses : azu/action-package-version-to-git-tag@v1
63+ with :
64+ version : ${{ env.CURRENT_VERSION }}
65+ github_token : ${{ secrets.GITHUB_TOKEN }}
66+ github_repo : ${{ github.repository }}
67+ git_commit_sha : ${{ github.sha }}
68+ git_tag_prefix : " v"
69+
70+ # Create Release
71+ - name : 📝 Create Release
72+ id : create-release
73+ if : steps.tag-check.outputs.exists_tag == 'false' && github.event.pull_request.merged == true
74+ uses : actions/create-release@v1
75+ env :
76+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
77+ with :
78+ tag_name : v${{ env.CURRENT_VERSION }}
79+ # Copy Pull Request's tile and body to Release Note
80+ release_name : ${{ github.event.pull_request.title }}
81+ body : |
82+ ${{ github.event.pull_request.body }}
83+ draft : false
84+ prerelease : false
85+
86+ # Publish
87+ - name : 🚀 Publish
88+ if : steps.tag-check.outputs.exists_tag == 'false'
89+ run : |
90+ yarn lerna publish from-package --yes
91+ env :
92+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
93+ NODE_AUTH_TOKEN : ${{ secrets.NPM_AUTH_TOKEN }}
94+ - uses : actions/github-script@0.8.0
95+ with :
96+ github-token : ${{secrets.GITHUB_TOKEN}}
97+ script : |
98+ github.issues.createComment({
99+ issue_number: context.issue.number,
100+ owner: context.repo.owner,
101+ repo: context.repo.repo,
102+ body: 'https://github.com/${{ github.repository }}/releases/tag/v${{ env.CURRENT_VERSION }} is released 🎉'
103+ })
0 commit comments