generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 29
135 lines (115 loc) · 4.49 KB
/
cd.yaml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: cd
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_run:
workflows:
- ci
types:
- completed
branches:
- master
env:
TERM: xterm
GO_VERSION: 1.19.6
MM_RUDDER_PLUGINS_PROD: ${{ secrets.MM_RUDDER_PLUGINS_PROD }}
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0 # We need these for proper release notes
- name: ci/setup-go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: ci/build
run: make dist
- name: ci/generate-release-notes
run: |
printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Enhancements\n\n## Fixes\n" >> dist/release-notes.md
if [[ $(git tag -l | wc -l) -eq 1 ]]; then
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git rev-list --max-parents=0 HEAD) HEAD >> dist/release-notes.md
else
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD >> dist/release-notes.md
fi
- name: ci/upload-artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: dist
path: |
dist/*.tar.gz
dist/release-notes.md
retention-days: 5 ## No need to keep CI builds more than 5 days
deploy-ci:
runs-on: ubuntu-22.04
if: ${{ github.ref_name == 'master' }}
needs:
- build
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: cd/rename-artifacts
run: mv dist/*.tar.gz dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz
- name: cd/setup-aws
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }}
- name: cd/artifact-upload
run: |
aws s3 cp dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz s3://mattermost-plugins-ci/ci/ --acl public-read --cache-control no-cache
release-s3:
runs-on: ubuntu-22.04
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- build
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: cd/rename-artifacts
run: |
mv dist/*.tar.gz dist/${GITHUB_REPOSITORY#*/}-latest.tar.gz
cp dist/${GITHUB_REPOSITORY#*/}-latest.tar.gz dist/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}.tar.gz
- name: cd/setup-aws
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }}
- name: cd/artifact-upload
run: |
aws s3 cp dist/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}.tar.gz s3://mattermost-plugins-ci/release/ --acl public-read --cache-control no-cache
release-github:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
needs:
- release-s3
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifact
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1
with:
name: dist
path: dist
- name: cd/create-github-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file dist/release-notes.md dist/*.tar.gz