-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (157 loc) Β· 6.13 KB
/
Copy pathrelease.yml
File metadata and controls
174 lines (157 loc) Β· 6.13 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
# Builds for all operating system platforms, and uploads executable to the release
# This workflow uses both self-hosted runners
name: Build and Upload Artifact
on:
release:
types:
- published
jobs:
lint-and-test:
uses:
./.github/workflows/pre-release.yml
with:
build: 'false'
release-check:
runs-on: thevickypedia-default
needs: lint-and-test
outputs:
release-id: ${{ steps.get-release-id.outputs.release_id }}
release-tag: ${{ steps.get-release-id.outputs.release_tag }}
steps:
- name: Check Release ID
id: get-release-id
run: |
if [ -n "${{ github.event.release.id }}" ]; then
echo "Release ID: ${{ github.event.release.id }}"
echo "release_id=${{ github.event.release.id }}" >> $GITHUB_OUTPUT
echo "release_tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "Failed to fetch current release id, trying to fetch externally"
release_id=$(curl -s -X GET \
-H "Authorization: token ${{ secrets.GIT_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" | \
jq -r ".id")
if [ -n "$release_id" ]; then
echo "Release ID: $release_id"
echo "release_id=$release_id" >> $GITHUB_OUTPUT
echo "release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
else
echo "::error title=Failed::Release ID not available in the event"
exit 1
fi
fi
shell: bash
# Upload assets for different OS and Architecture
build-and-upload:
if: ${{ github.event_name == 'release' }}
needs: release-check
strategy:
matrix:
platform:
# Naming Convention: {operating_system}-{architecture}-{package_name}.{archive_format}
- release_for: darwin-amd64
bin: filebrowser
name: darwin-amd64-filebrowser.tar.gz
pkg-name: darwin-amd64-filebrowser
- release_for: darwin-arm64
bin: filebrowser
name: darwin-arm64-filebrowser.tar.gz
pkg-name: darwin-arm64-filebrowser
- release_for: linux-amd64
bin: filebrowser
name: linux-amd64-filebrowser.tar.gz
pkg-name: linux-amd64-filebrowser
- release_for: linux-arm64
bin: filebrowser
name: linux-arm64-filebrowser.tar.gz
pkg-name: linux-arm64-filebrowser
- release_for: windows-amd64
bin: filebrowser.exe
name: windows-amd64-filebrowser.zip
pkg-name: windows-amd64-filebrowser
name: Upload asset for ${{ matrix.platform.release_for }}
runs-on: ${{ matrix.platform.release_for }}
permissions:
contents: write
steps:
- name: Release ID Propagation
run: |
if [ -n "${{ needs.release-check.outputs.release-id }}" ]; then
echo "Release ID propagated: ${{ needs.release-check.outputs.release-id }}"
else
echo "Release ID propagation failed. Exiting.."
exit 1
fi
echo "start_time=$(date +%s)" >> "$GITHUB_ENV"
shell: bash
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.25'
- uses: actions/setup-node@v4
with:
node-version: "24.x"
- uses: pnpm/action-setup@v4
with:
package_json_file: "frontend/package.json"
dest: ${{ runner.temp }}/setup-pnpm-${{ github.job }}-${{ github.run_id }}
# IMPORTANT: frontend should be built first, since it is required when creating the binary
- name: Build Frontend
run: make build-frontend
shell: bash
- name: Build Backend
run: make build-backend
shell: bash
- name: Copy Asset (Windows)
if: startsWith(matrix.platform.release_for, 'windows')
run: |
mkdir -p ${{ matrix.platform.pkg-name }}
cp ${{ matrix.platform.bin }} ${{ matrix.platform.pkg-name }}/${{ matrix.platform.bin }}
Compress-Archive -DestinationPath ${{ matrix.platform.name }} -Path ${{ matrix.platform.pkg-name }}
shell: pwsh
- name: Copy Asset (macOS/Linux/RaspberryPi)
if: "!startsWith(matrix.platform.release_for, 'windows')"
run: |
mkdir -p ${{ matrix.platform.pkg-name }}
cp ${{ matrix.platform.bin }} ${{ matrix.platform.pkg-name }}/${{ matrix.platform.bin }}
tar -zcvf ${{ matrix.platform.name }} ${{ matrix.platform.pkg-name }}
shell: bash
- name: Upload Artifact
run: |
curl -X POST -H "Authorization: token ${{ secrets.GIT_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"${{ matrix.platform.name }}" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ needs.release-check.outputs.release-id }}/assets?name=${{ matrix.platform.name }}"
shell: bash
- name: Runtime Analyzer
run: |
start=${{ env.start_time }}
end=$(date +%s)
time_taken=$((end-start))
url="${{ github.server_url }}/${{ github.repository }}/releases/download/${{ needs.release-check.outputs.release-tag }}/${{ matrix.platform.name }}"
hyperlink="[${{ matrix.platform.release_for }}]($url)"
echo "π Built for $hyperlink in $time_taken seconds" >> $GITHUB_STEP_SUMMARY
shell: bash
docker-publish-release:
if: ${{ github.event_name == 'release' }}
needs:
- release-check
- build-and-upload
uses:
./.github/workflows/build-publish.yml
with:
tag_name: ${{ needs.release-check.outputs.release-tag }}
dockerfile: 'thevickypedia/docker/release/Dockerfile'
secrets: inherit
docker-build-and-publish:
if: ${{ github.event_name == 'release' }}
needs:
- release-check
uses:
./.github/workflows/build-publish.yml
with:
tag_name: ${{ needs.release-check.outputs.release-tag }}
dockerfile: 'thevickypedia/docker/base/Dockerfile'
secrets: inherit