-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (121 loc) · 4.54 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
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: cache node_modules
uses: actions/cache@v3
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-node_modules-
- run: yarn --frozen-lockfile
- name: Get Version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- run: yarn lerna run build
env:
BUILD_VERSION: ${{ env.VERSION }}
- name: upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: packages/snage/build/npm
release-docker-npm:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build
path: packages/snage/build/npm
- name: Get Version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Publish Release to Docker and NPM
run: |
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USER" --password-stdin
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > $HOME/.npmrc
docker build -t snage/snage:${VERSION} packages/snage
docker push snage/snage:${VERSION}
(cd packages/snage && yarn publish --new-version "${VERSION}" --no-git-tag-version)
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
release-artifact:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build
path: packages/snage/build/npm
- name: Get Version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Create release artifact
run: |
mkdir -p packages/snage/build/github/snage-${VERSION}
cp -r LICENSE packages/snage/build/npm/snage.js packages/snage/build/npm/ui packages/snage/build/github/snage-${VERSION}
tar -cvzf snage-${VERSION}.tar.gz -C packages/snage/build/github snage-${VERSION}
RELEASE_ID=$(curl "https://api.github.com/repos/FACT-Finder/snage/releases/tags/v${VERSION}" | jq -r '.id')
curl \
--fail \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-type: application/gzip" \
--data-binary @snage-${VERSION}.tar.gz \
"https://uploads.github.com/repos/FACT-Finder/snage/releases/${RELEASE_ID}/assets?name=snage-${VERSION}.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-aur:
runs-on: ubuntu-latest
needs: [build, release-artifact]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build
- name: Get Version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Publish to Archlinux User Repository
run: |
mkdir $HOME/.ssh
echo "$SSH_KEY" > $HOME/.ssh/id_rsa
chmod 700 $HOME/.ssh && chmod 600 $HOME/.ssh/id_rsa
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts
git clone ssh://[email protected]/snage.git aur-snage
(
cd aur-snage;
sed -i -E 's/pkgrel=[0-9]+/pkgrel=1/g' PKGBUILD;
sed -i -E "s/pkgver=[0-9.]+/pkgver=${VERSION}/g" PKGBUILD;
bash updpkgsums-printsrcinfo-build.sh;
git config user.email "[email protected]";
git config user.name "SnageCI";
git add PKGBUILD .SRCINFO;
git commit -m "Update to version ${VERSION}";
git push;
)
git clone ssh://[email protected]/snage-bin.git aur-snage-bin
(
cd aur-snage-bin;
sed -i -E 's/pkgrel=[0-9]+/pkgrel=1/g' PKGBUILD;
sed -i -E "s/pkgver=[0-9.]+/pkgver=${VERSION}/g" PKGBUILD;
bash updpkgsums-printsrcinfo-build.sh;
git config user.email "[email protected]";
git config user.name "SnageCI";
git add PKGBUILD .SRCINFO;
git commit -m "Update to version ${VERSION}";
git push;
)
env:
SSH_KEY: ${{ secrets.SSH_KEY }}