generated from wabarc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
126 lines (107 loc) · 3.89 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
# Copyright 2023 Wayback Archiver. All rights reserved.
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file.
name: Release
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
PRODUCT: cairn
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
name: Checkout, build
runs-on: ubuntu-latest
steps:
- name: Set up Node 18.x
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Check out code into the Go module directory
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Get dependencies
run: yarn install
- name: Build package
run: yarn build
- name: Packaging
run: yarn package
- name: Create artifact
run: tar -zcf ${{ env.PRODUCT }}-dist.tar.gz --exclude=dist/linux --exclude=dist/macos --exclude=dist/windows dist/*
- name: Upload artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ${{ env.PRODUCT }}
path: |
${{ env.PRODUCT }}-dist.tar.gz
build/Release/${{ env.PRODUCT }}*
if-no-files-found: error
release:
name: Create and upload release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Check out code base
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
fetch-depth: 0
- name: Download math result from build and checksum jobs
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: ${{ env.PRODUCT }}
path: ${{ env.PRODUCT }}
- name: Generate Git log
run: |
git fetch origin +refs/tags/*:refs/tags/*
echo "Current Tag: ${GITHUB_REF}"
git checkout ${GITHUB_REF} -b release-log
GITVER=$(git describe --tags)
PREVVER=$(git describe --tags --abbrev=0 ${GITVER}~1)
git log --oneline ${PREVVER}..${GITVER} > gittaglogs.txt
MORE=$(echo "See more on [releases](https://github.com/${{ github.repository }}/releases)")
echo -e "*Release ${GITVER}* #${{ env.PRODUCT }}\n" > release-note.md
cut -c9- gittaglogs.txt | sed -e 's/^/- /' | sed -e 's/\"/\\"/g' >> release-note.md
echo -e "\n${MORE}" | tee -a release-note.md > /dev/null
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: release-note
path: release-note.md
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
body_path: gittaglogs.txt
files: |
${{ env.PRODUCT }}/*${{ env.PRODUCT }}*
${{ env.PRODUCT }}/build/Release/${{ env.PRODUCT }}*
prerelease: true
draft: false
notification:
name: Send Notification
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Download artifact
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: release-note
path: .
- name: Send release note to Telegram channel
continue-on-error: true
run: |
TEXT="$(cat release-note.md)"
echo -e "${TEXT}"
curl --silent --output /dev/null --show-error --fail -X POST \
-H 'Content-Type: application/json' \
-d '{"chat_id": "${{ secrets.TELEGRAM_TO }}", "text": "'"${TEXT}"'", "parse_mode": "markdown"}' \
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage"