Skip to content

Commit f24a741

Browse files
committed
add release automation
1 parent 7b75e7a commit f24a741

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Release"
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: '12'
16+
17+
- name: Create release branch and bump version
18+
env:
19+
REF: ${{ github.ref }}
20+
run: |
21+
BRANCH=release/${REF:10}
22+
git config --local user.email "ci@pterodactyl.io"
23+
git config --local user.name "Pterodactyl CI"
24+
git checkout -b $BRANCH
25+
git push -u origin $BRANCH
26+
sed -i "s/ 'version' => 'canary',/ 'version' => '${REF:11}',/" config/app.php
27+
git add config/app.php
28+
git commit -m "bump version for release"
29+
git push
30+
31+
- name: Build assets
32+
run: |
33+
yarn install
34+
yarn run build:production
35+
36+
- name: Create release archive
37+
run: |
38+
rm -rf node_modules/ test/ codecov.yml CODE_OF_CONDUCT.md CONTRIBUTING.md phpunit.dusk.xml phpunit.xml Vagrantfile
39+
tar -czf panel.tar.gz *
40+
41+
- name: Extract changelog
42+
id: extract_changelog
43+
env:
44+
REF: ${{ github.ref }}
45+
run: |
46+
sed -n "/^## ${REF:10}/,/^## /{/^## /b;p}" CHANGELOG.md > ./RELEASE_CHANGELOG
47+
echo ::set-output name=version_name::`sed -nr "s/^## (${REF:10} .*)$/\1/p" CHANGELOG.md`
48+
49+
- name: Create checksum and add to changelog
50+
run: |
51+
SUM=`sha256sum panel.tar.gz`
52+
echo -e "\n#### SHA256 Checksum\n\n\`\`\`\n$SUM\n\`\`\`\n" >> ./RELEASE_CHANGELOG
53+
echo $SUM > checksum.txt
54+
55+
- name: Create Release
56+
id: create_release
57+
uses: actions/create-release@v1
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
with:
61+
tag_name: ${{ github.ref }}
62+
release_name: ${{ steps.extract_changelog.outputs.version_name }}
63+
body_path: ./RELEASE_CHANGELOG
64+
draft: true
65+
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
66+
67+
- name: Upload binary
68+
id: upload-release-archive
69+
uses: actions/upload-release-asset@v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
upload_url: ${{ steps.create_release.outputs.upload_url }}
74+
asset_path: panel.tar.gz
75+
asset_name: panel.tar.gz
76+
asset_content_type: application/gzip
77+
78+
- name: Upload checksum
79+
id: upload-release-checksum
80+
uses: actions/upload-release-asset@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
upload_url: ${{ steps.create_release.outputs.upload_url }}
85+
asset_path: ./checksum.txt
86+
asset_name: checksum.txt
87+
asset_content_type: text/plain

0 commit comments

Comments
 (0)