forked from block-wallet/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (115 loc) · 5.08 KB
/
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Release (automated)
on:
pull_request:
types:
- closed
env:
S3_PATH: s3://releases.blockwallet.io/extension
jobs:
release:
outputs:
extension: ${{ steps.get_metadata.outputs.extension }}
html_url: ${{ steps.create_release.outputs.html_url }}
s3_url: ${{ steps.get_metadata.outputs.s3_url }}
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'automated') && contains(github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_RELEASE_BUCKET }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_RELEASE_BUCKET }}
aws-region: eu-central-1
- name: Get release version and notes
id: get_metadata
run: |
aws s3 cp $S3_PATH/version.json .
aws s3 cp $S3_PATH/notes.md .
extension=$(cat version.json | jq -r .extension)
prerelease=$(cat version.json| jq -r .prerelease)
notes=$(cat notes.md)
notes="${notes//'%'/'%25'}" # hack to share multiline strings as action output
notes="${notes//$'\n'/'%0A'}" # hack to share multiline strings as action output
notes="${notes//$'\r'/'%0D'}" # hack to share multiline strings as action output
s3_url=$(echo "${S3_PATH/s3/https}")
echo "::set-output name=extension::$extension"
echo "::set-output name=pre-release::$prerelease"
echo "::set-output name=notes::$notes"
echo "::set-output name=s3_url::$s3_url"
- name: Install semver package
run: |
wget -O /usr/local/bin/semver \https://raw.githubusercontent.com/block-wallet/release-helpers/main/semver
chmod +x /usr/local/bin/semver
- name: Compare release version with the latest tag
id: tag_comparison
run: |
latest_tag=$(git ls-remote --tags --sort='v:refname' origin | cut --delimiter='/' --fields=3 | tail -n 1)
if [[ -z $latest_tag ]]
then
result=1
else
result=$(semver compare ${{ steps.get_metadata.outputs.extension }} $latest_tag)
fi
echo "::set-output name=result::$result"
- name: Parse extension semver string
id: semver_extension
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ steps.get_metadata.outputs.extension }}
version_extractor_regex: 'v(.*)$'
- name: Create release
uses: ncipollo/[email protected]
if: ${{ steps.tag_comparison.outputs.result == 1 }}
id: create_release
with:
draft: true
prerelease: ${{ steps.get_metadata.outputs.pre-release }}
tag: '${{ steps.get_metadata.outputs.extension }}'
commit: 'master'
token: ${{ secrets.PAT }}
generateReleaseNotes: true
body: |
# Extension
- [zip](${{ steps.get_metadata.outputs.s3_url }}/block-wallet-${{ steps.get_metadata.outputs.extension }}.zip)
- [sha256 checksum](${{ steps.get_metadata.outputs.s3_url }}/block-wallet-${{ steps.get_metadata.outputs.extension }}.checksum)
${{ steps.get_metadata.outputs.notes }}
notify:
if: success()
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Slack notification - Release
if: success()
uses: 8398a7/action-slack@v3
with:
status: custom
fields: repo,workflow
github_token: ${{ secrets.PAT }}
custom_payload: |
{
"text": "*Release (automated)* for ${{ needs.release.outputs.extension }} finished.",
"attachments": [
{
"color": "good",
"pretext": "New release ${{ needs.release.outputs.extension }}: <${{ needs.release.outputs.s3_url }}/block-wallet-${{ needs.release.outputs.extension }}.zip| extension.zip> and <${{ needs.release.outputs.s3_url }}/block-wallet-${{ needs.release.outputs.extension }}.checksum| checksum>. After uploading it to the store please publish the GitHub Release to finish the release process.\nCC: <@U01H6J242BY>, <@U021GBLL00Z>, <@U01HRUM7XUH>",
"author_name": "GitHub Release ${{ needs.release.outputs.extension }}",
"author_link": "${{ needs.release.outputs.html_url }}",
"title": "GitHub Release ${{ needs.release.outputs.extension }} has been created as a draft."
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_BLOCKWALLET_RELEASES }}
error:
if: failure()
needs: [release, notify]
runs-on: ubuntu-latest
steps:
- name: Slack notification - CI status
uses: 8398a7/action-slack@v3
with:
status: failure
fields: workflow
github_token: ${{ secrets.PAT }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ALERTS_RELEASES }}