forked from aragon/aragon-apps
-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (113 loc) · 4.03 KB
/
release.yml
File metadata and controls
117 lines (113 loc) · 4.03 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Release
on:
pull_request_target:
types: [closed]
env:
POSSIBLE_NETWORKS: "mainnet rinkeby mumbai matic harmony harmonyTest "
jobs:
checkLabels:
runs-on: ubuntu-latest
if: github.event.pull_request.merged && github.event.pull_request.labels.*.name && github.base_ref == 'master'
steps:
- run: echo Check labels is not empty and pull is merged
buildMatrix:
needs: [checkLabels]
runs-on: ubuntu-latest
outputs:
labels: ${{ steps.matrix.outputs.labels }}
networks: ${{ steps.networks.outputs.networks }}
valid: ${{ steps.matrix.outputs.valid }}
steps:
- name: Get Networks
id: networks
env:
PULL_LABELS: ${{ toJson(github.event.pull_request.labels) }}
run: |
NETWORKS=""
for LABEL in $(echo $PULL_LABELS | jq -r '.[].name'); do
if [[ $POSSIBLE_NETWORKS =~ (^|[[:space:]])$LABEL($|[[:space:]]) ]]; then
NETWORKS+=" $LABEL"
fi
done
echo "::set-output name=networks::$(jq -c -n --arg v "${NETWORKS:1}" '$v | split(" ")')"
- name: Build Matrix
id: matrix
env:
PULL_LABELS: ${{ toJson(github.event.pull_request.labels) }}
NETWORKS: ${{ steps.networks.outputs.networks }}
# loop through all labels and prepare matrix to run in the next job
run: |
LABELS=()
for LABEL in $(echo $PULL_LABELS | jq -r '.[].name'); do
APP=$(cut -d":" -f1 <<< $LABEL)
LEVEL=$(cut -d":" -f2 <<< $LABEL)
if [ $LEVEL = 'minor' ] || [ $LEVEL = 'major' ] || [ $LEVEL = 'patch' ]; then
for NETWORK in $(echo $NETWORKS | jq -r '.[]'); do
LABELS[${#LABELS[@]}]="{\"app\": \"$APP\", \"level\": \"$LEVEL\", \"network\": \"$NETWORK\"}"
done
fi
done
if [ ${#LABELS[@]} -eq 0 ]; then
echo "::set-output name=valid::false"
else
JSON="["
for i in "${LABELS[@]}"; do
JSON+="$i,"
done
JSON="${JSON::-1}]"
echo "::set-output name=labels::{\"include\":$JSON}"
echo "::set-output name=valid::true"
fi
release:
needs: [buildMatrix]
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && needs.buildMatrix.outputs.valid == 'true'
strategy:
matrix: ${{ fromJson(needs.buildMatrix.outputs.labels) }}
fail-fast: false
environment: ${{ matrix.network }}
steps:
- uses: actions/checkout@v2
with:
ref: 'master'
- name: Install node
uses: actions/setup-node@v1
with:
node-version: 14
- name: setup ipfs
uses: ibnesayeed/setup-ipfs@master
with:
run_daemon: true
- name: Configure aragon cli
run: |
mkdir -p ~/.aragon
echo ${{ secrets.ARAGON_CLI_JSON }} >> ~/.aragon/${{ matrix.network }}_key.json
- name: Install npm packages
run: yarn
- name: build, publish and package
id: build
run: |
cd apps/${{ matrix.app }}
yarn --ignore-engines --dev
if [[ -d app ]]; then
yarn build
fi
- name: publish
id: publish
run: |
cd apps/${{ matrix.app }}
PUBLISH_MESSAGE=$(npx hardhat publish ${{ matrix.level }} --dry-run --skip-validation --skip-app-build --network ${{ matrix.network }})
echo "::set-output name=version::$(echo $PUBLISH_MESSAGE | sed -nE 's/^.*next version: *([^ ]*) *.*$/\1/p')"
- name: create tag
uses: actions/github-script@v5
env:
TAG_NAME: "${{ steps.publish.outputs.version }}-${{ matrix.app }}-${{ matrix.network }}"
with:
github-token: ${{ secrets.ARABOT_PAT }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.TAG_NAME}`,
sha: context.sha
})