forked from LinkStackOrg/LinkStack
-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (145 loc) · 5.75 KB
/
release.yml
File metadata and controls
195 lines (145 loc) · 5.75 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Setup Ubuntu with Composer and PHP 8
on:
push:
tags:
- '*'
jobs:
build-and-release:
runs-on: ubuntu-24.04
steps:
- name: Updating Dependencies + zip
run: |
cd ~
sudo apt install -y curl rsync git php8.3
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
sudo update-alternatives --set php /usr/bin/php8.3
cd /tmp
mkdir linkstack
cd linkstack
TAG_VERSION="${GITHUB_REF##*/}"
version=${TAG_VERSION#"v"}
echo "$version" > version.json
git clone https://github.com/LinkStackOrg/LinkStack/
mkdir linkstack
mv LinkStack linkstack/linkstack
cd linkstack
curl -o README.md https://gist.githubusercontent.com/JulianPrieber/7a3f18a404c524d59c147a8d4f1ad33c/raw/3008f0893da2effaee56b99ee8b956fa533d9b07/README.md
cd linkstack
cp "../../version.json" "version.json"
composer update --no-scripts
php artisan lang:update
php artisan migrate
php artisan db:seed
php artisan db:seed --class="PageSeeder"
php artisan db:seed --class="ButtonSeeder"
rm -r ".git"
rm -r ".github"
rm README.md
cd ../../
rsync -av linkstack/linkstack update
cd update
mv linkstack/database/database.sqlite database.sqlite
curl -o "HOW TO UPDATE.md" https://gist.githubusercontent.com/JulianPrieber/afc782666cf8c8f7a1a9cb9928498af5/raw/dbbbefb3c88ecd7703efbc866209629d9d130659/HOW%2520TO%2520UPDATE.md
rm linkstack/INSTALLING
cd ..
rsync -av linkstack/linkstack/ "$version"
rm "$version/.env"
rm "$version/INSTALLING"
rm "$version/database/database.sqlite"
cp version.json "$version/version.json"
echo "v$version" > "$version/vbeta.json"
touch /tmp/linkstack/linkstack/linkstack/storage/app/ISINSTALLED
cd /tmp/linkstack
cd "$version"
zip -r "$version.zip" *
mv "$version.zip" ../
cd ..
cd linkstack
zip -r "linkstack.zip" *
mv linkstack.zip ../
cd ..
cd update
zip -r "update.zip" *
mv update.zip ../
cd ..
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: linkstack.zip
path: /tmp/linkstack/linkstack.zip
- run: pwd
- run: ls -al
- name: Create GitHub Release
if: ${{ github.event_name == 'push' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd /tmp/linkstack
# Get the repository name in the format 'OWNER/REPO'
REPO_NAME="YamiDoesDev/LinkStack"
# create release
gh release create "${GITHUB_REF##*/}" \
--title "${GITHUB_REF##*/}" \
--notes "Automated release for ${GITHUB_REF##*/}" \
-R "$REPO_NAME"
# Upload 'update.zip'
gh release upload "${GITHUB_REF##*/}" "update.zip" --clobber -R "$REPO_NAME"
# Upload 'linkstack.zip'
gh release upload "${GITHUB_REF##*/}" "linkstack.zip" --clobber -R "$REPO_NAME"
# Mark the release as the latest
gh release edit "${GITHUB_REF##*/}" --title="${GITHUB_REF##*/}" -R "$REPO_NAME"
- name: Update version.json
if: ${{ github.event_name == 'push' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# The repository and file path
repo="YamiDoesDev/LinkStack"
file_path="version.json"
# Fetch the latest commit's SHA for the file
sha=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/$repo/contents/$file_path" | grep -oP '(?<="sha": ")[^"]+')
# Get version from version.json
cd /tmp/linkstack
TAG_VERSION="${GITHUB_REF##*/}"
version=${TAG_VERSION#"v"}
# JSON payload with the new content
payload="{\"message\": \"Update version.json to $version\", \"content\": \"$(echo -ne "$version\n" | base64 -w 0)\", \"sha\": \"$sha\"}"
# API endpoint to create a new commit
url="https://api.github.com/repos/$repo/contents/$file_path"
# Make the API request to update the file
curl -X PUT -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d "$payload" "$url"
docker:
needs: build-and-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/linkstack
tags: |
type=semver,pattern={{version}}
- uses: actions/download-artifact@v5
with:
name: linkstack.zip
path: ./docker
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./docker
push: true
platforms: linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}