-
Notifications
You must be signed in to change notification settings - Fork 3
104 lines (91 loc) · 2.79 KB
/
build_and_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: 🚀 Build and release
on:
push:
branches:
- main
paths:
- src/**
- action.yml
- package.json
- package-lock.json
jobs:
build_and_push:
runs-on: ubuntu-latest
outputs:
branch: v${{ steps.version.outputs.major }}
tag: v${{ steps.pack.outputs.version }}
steps:
- name: ⚙️ Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: 🔃 Checkout
uses: actions/checkout@v2
- name: 🛠️ Install and build
run: |
npm ci
npm i -g @vercel/ncc
npm run build
- name: 📦 Zip dist files
id: pack
uses: ./
with:
files: dist, action.yml
- name: ⚙️ Unzip dist files
run: |
mkdir TODEPLOY
unzip ${{ steps.pack.outputs.archive }} -d TODEPLOY
- name: ⚙️ Parse version string
id: version
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ steps.pack.outputs.version }}
- name: 📢 Publish dist files to dist branch
uses: s0/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: self
BRANCH: v${{ steps.version.outputs.major }}
FOLDER: TODEPLOY
SKIP_EMPTY_COMMITS: true
tag_version:
needs: build_and_push
runs-on: ubuntu-latest
outputs:
tagged: ${{ steps.check_tagged.outputs.tagged }}
tag: ${{ steps.tag.outputs.new_tag }}
steps:
- name: 🔃 Checkout dist branch
uses: actions/checkout@v2
with:
ref: ${{ needs.build_and_push.outputs.branch }}
fetch-depth: 0
- name: ⚙️ Check tag exists
id: check_tag
uses: mukunku/[email protected]
with:
tag: ${{ needs.build_and_push.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔖 Tag version
id: tag
if: ${{ steps.check_tag.outputs.exists == 'false' }}
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: ${{ needs.build_and_push.outputs.tag }}
- name: ⚙️ Check created tag
id: check_tagged
run: |
echo "::set-output name=tagged::${{ (steps.check_tag.outputs.exists == 'false') && (steps.tag.outputs.new_tag == steps.tag.outputs.tag) }}"
create_release:
needs: tag_version
if: ${{ needs.tag_version.outputs.tagged == 'true' }}
runs-on: ubuntu-latest
steps:
- name: 🛎️ Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.tag_version.outputs.tag }}
draft: true