-
-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (109 loc) · 3.8 KB
/
main.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: Build
on:
release:
types: [published]
push:
jobs:
BuildBinary:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v3.6.0
with:
node-version: 16.x
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y jq
- name: Build
run: |
export VERSION="`if [[ $GITHUB_REF == refs\/tags* ]]; then echo ${GITHUB_REF//refs\/tags\//}; fi`"
if [ "$VERSION" = "" ];
then
export VERSION="SNAPSHOT"
fi
bash build.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: hypergate
path: deploy
- name: Deploy to GitHub Releases
if: github.event_name == 'release'
run: |
echo "${GITHUB_EVENT_PATH}"
cat ${GITHUB_EVENT_PATH}
releaseId=$(jq --raw-output '.release.id' ${GITHUB_EVENT_PATH})
echo "Upload binary to $releaseId"
filename=deploy/hypergate
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)"
echo "Upload to $url"
curl -L \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$filename" \
"$url"
echo "Upload hash to $releaseId"
filename=deploy/hypergate.sha256
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)"
echo "Upload to $url"
curl -L \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: text/plain" \
--data-binary @"$filename" \
"$url"
BuildContainer:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y jq
- name: Build and push to registry
run: |
VERSION="snapshot"
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
bash setversion.sh
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
docker build -t hypergate:$VERSION . -f docker/Dockerfile
docker tag hypergate:$VERSION docker.pkg.github.com/${{ github.repository }}/hypergate:${VERSION}
docker push docker.pkg.github.com/${{ github.repository }}/hypergate:${VERSION}
# BuildWithNPM:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# steps:
# - uses: actions/checkout@v2
# - name: Setup Node.js environment
# uses: actions/setup-node@v3.6.0
# with:
# node-version: 16.x
# registry-url: 'https://npm.pkg.github.com'
# - name: Install dependencies
# run: |
# sudo apt update
# sudo apt install -y jq
# - name: Build
# run: |
# VERSION="snapshot"
# if [[ $GITHUB_REF == refs/tags/* ]]; then
# VERSION=${GITHUB_REF#refs/tags/}
# fi
# bash setversion.sh
# npm install --production
# - name: Publish
# run: |
# echo @lexacode:https://npm.pkg.github.com/ > .npmrc
# echo '//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}' >> .npmrc
# npm publish