Skip to content

Commit 2dd17e9

Browse files
authored
Sync changes from Frontend (#210)
1 parent 6ce2e4c commit 2dd17e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+644
-556
lines changed

.dockerignore

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
*
2-
!src/
3-
!bun.lockb
4-
!bunfig.toml
5-
!LICENSE
6-
!package.json
7-
!tsconfig.json
2+
3+
# Project files
4+
!/bun.lock
5+
!/bunfig.toml
6+
!/LICENSE
7+
!/package.json
8+
!/tsconfig.json
9+
10+
# SRC
11+
!/src/**

.env.example

+31-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1+
#? Rename or copy this file to ".env" and set the variables there.
2+
#?
3+
#?####################
4+
#? VARIABLE STRUCTURE:
5+
#?####################
6+
#? [ default ] : type < min - max >
7+
#? ^ ^ ^
8+
#? | | |
9+
#? | | +---- RANGE between two values (these included)
10+
#? | +-------------- TYPE of the variable
11+
#? +------------------------ DEFAULT value applied if not set
12+
#?
13+
#?###################
14+
#? COMMENT STRUCTURE:
15+
#?###################
16+
#? "#?#..." or "###..." are used to comment a section line.
17+
#? "#?" is used to comment a help line.
18+
#? "##" is used to comment a description line.
19+
#? "#" is used to comment a variable line.
20+
#?
21+
#? You should remove the comment on variable lines only if you want to set the variable.
22+
23+
##########
124
## SERVER:
2-
# Set log verbosity [3]:integer
3-
# (0=none <- 1=error <- 2=warn <- 3=info <- 4=debug)
25+
##########
26+
## Set log verbosity [3]:integer
27+
#? (0=none <- 1=error <- 2=warn <- 3=info <- 4=debug)
428
#LOGLEVEL=3
529

6-
# Port for the server [4000]:integer
30+
## Port for the server [4000]:integer
731
#PORT=4000
832

9-
# Root path for the server (NOT IMPLEMENTED) [/api]:string
10-
# (Everything will be served under this path)
11-
#PATH=/api
12-
13-
# Is website served over HTTPS? [true]:boolean
33+
## Is website served over HTTPS? [true]:boolean
1434
#TLS=true
1535

36+
############
1637
## DOCUMENT:
17-
# Maximum document size in kilobytes [1024]:integer
38+
############
39+
## Maximum document size in kilobytes [1024]:integer
1840
#DOCUMENT_MAXSIZE=1024

.gitattributes

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*.cmd text eol=crlf
88
*.coffee text
99
*.css text diff=css
10+
*.go text diff=golang
1011
*.htm text diff=html
1112
*.html text diff=html
1213
*.inc text
@@ -66,6 +67,7 @@ LICENSE text
6667
NEWS text
6768
readme text
6869
*README* text
70+
TODO text
6971

7072
# Templates
7173
*.dot text
@@ -95,8 +97,7 @@ readme text
9597
.gitattributes text
9698
.gitconfig text
9799
.htaccess text
98-
*.lock text -diff
99-
*.lockb binary diff=lockb
100+
*.lock text eol=lf -diff
100101
package.json text eol=lf
101102
package-lock.json text eol=lf -diff
102103
pnpm-lock.yaml text eol=lf -diff
@@ -184,8 +185,6 @@ Procfile text
184185
# Executables
185186
*.exe binary
186187
*.pyc binary
187-
**/.yarn/releases/** binary
188-
**/.yarn/plugins/** binary
189188

190189
# RC files (like .babelrc or .eslintrc)
191190
*.*rc text

.github/dependabot.yml

-9
This file was deleted.

.github/renovate.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:recommended"],
4+
"lockFileMaintenance": {
5+
"enabled": true,
6+
"automerge": true
7+
},
8+
"packageRules": [
9+
{
10+
"matchUpdateTypes": ["patch"],
11+
"automerge": true
12+
}
13+
]
14+
}

.github/workflows/cd.yml

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
---
2+
name: CD
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
artifact-action:
7+
description: Artifact action
8+
type: choice
9+
required: true
10+
default: none
11+
options:
12+
- none
13+
- build
14+
- build-release
15+
image-action:
16+
description: Container image action
17+
type: choice
18+
required: true
19+
default: none
20+
options:
21+
- none
22+
- build
23+
- build-release
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: false
28+
29+
permissions:
30+
contents: read
31+
32+
jobs:
33+
artifact:
34+
if: github.repository_owner == 'jspaste' && inputs.artifact-action != 'none'
35+
name: Release artifact
36+
runs-on: ubuntu-latest
37+
permissions:
38+
attestations: write
39+
contents: write
40+
id-token: write
41+
42+
steps:
43+
- name: Harden Runner
44+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
45+
with:
46+
egress-policy: audit
47+
48+
- name: Setup Bun
49+
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2.0.1
50+
51+
- name: Save context
52+
id: ctx
53+
env:
54+
CTX_BRANCH: ${{ github.head_ref || github.ref_name }}
55+
CTX_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
56+
run: |
57+
echo "branch=${CTX_BRANCH}" >>"$GITHUB_OUTPUT"
58+
echo "sha=${CTX_SHA}" >>"$GITHUB_OUTPUT"
59+
echo "sha_short=${CTX_SHA::7}" >>"$GITHUB_OUTPUT"
60+
61+
- name: Save tags
62+
id: tags
63+
env:
64+
BRANCH: ${{ steps.ctx.outputs.branch }}
65+
SHA_SHORT: ${{ steps.ctx.outputs.sha_short }}
66+
run: |
67+
TIMESTAMP="$(date +%Y.%m.%d)"
68+
69+
if [[ "${BRANCH}" == "stable" ]]; then
70+
TAG="latest"
71+
else
72+
TAG="snapshot"
73+
fi
74+
75+
echo "tag=${TAG}" >>"$GITHUB_OUTPUT"
76+
echo "extended=${TIMESTAMP}-${SHA_SHORT}" >>"$GITHUB_OUTPUT"
77+
78+
- name: Checkout
79+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+
with:
81+
persist-credentials: false
82+
83+
- name: Install deps
84+
run: bun install --frozen-lockfile
85+
86+
- name: Build artifact
87+
run: |
88+
bun run build:server
89+
90+
bun run build:standalone:darwin-arm64
91+
chmod 755 ./dist/server
92+
tar -c --owner=0 --group=0 --mtime='now' --utc .env.example LICENSE README.md -C ./dist/ server | xz -z -6 >./dist/backend_${{ steps.tags.outputs.tag }}_darwin-arm64.tar.xz
93+
tar -tJf ./dist/backend_${{ steps.tags.outputs.tag }}_darwin-arm64.tar.xz >/dev/null
94+
95+
bun run build:standalone:linux-amd64-glibc
96+
chmod 755 ./dist/server
97+
tar -c --owner=0 --group=0 --mtime='now' --utc .env.example LICENSE README.md -C ./dist/ server | xz -z -6 >./dist/backend_${{ steps.tags.outputs.tag }}_linux-amd64-glibc.tar.xz
98+
tar -tJf ./dist/backend_${{ steps.tags.outputs.tag }}_linux-amd64-glibc.tar.xz >/dev/null
99+
100+
bun run build:standalone:linux-amd64-musl
101+
chmod 755 ./dist/server
102+
tar -c --owner=0 --group=0 --mtime='now' --utc .env.example LICENSE README.md -C ./dist/ server | xz -z -6 >./dist/backend_${{ steps.tags.outputs.tag }}_linux-amd64-musl.tar.xz
103+
tar -tJf ./dist/backend_${{ steps.tags.outputs.tag }}_linux-amd64-musl.tar.xz >/dev/null
104+
105+
bun run build:standalone:linux-arm64-glibc
106+
chmod 755 ./dist/server
107+
tar -c --owner=0 --group=0 --mtime='now' --utc .env.example LICENSE README.md -C ./dist/ server | xz -z -6 >./dist/backend_${{ steps.tags.outputs.tag }}_linux-arm64-glibc.tar.xz
108+
tar -tJf ./dist/backend_${{ steps.tags.outputs.tag }}_linux-arm64-glibc.tar.xz >/dev/null
109+
110+
bun run build:standalone:linux-arm64-musl
111+
chmod 755 ./dist/server
112+
tar -c --owner=0 --group=0 --mtime='now' --utc .env.example LICENSE README.md -C ./dist/ server | xz -z -6 >./dist/backend_${{ steps.tags.outputs.tag }}_linux-arm64-musl.tar.xz
113+
tar -tJf ./dist/backend_${{ steps.tags.outputs.tag }}_linux-arm64-musl.tar.xz >/dev/null
114+
115+
bun run build:standalone:windows-amd64
116+
chmod 755 ./dist/server.exe
117+
zip -j -X -9 -l -o ./dist/backend_${{ steps.tags.outputs.tag }}_windows-amd64.zip .env.example LICENSE README.md ./dist/server.exe
118+
zip -T ./dist/backend_${{ steps.tags.outputs.tag }}_windows-amd64.zip
119+
120+
- if: inputs.artifact-action == 'build-release'
121+
name: Release artifact
122+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
123+
with:
124+
name: ${{ steps.tags.outputs.extended }}
125+
tag: ${{ steps.tags.outputs.extended }}
126+
artifacts: dist/*.tar.xz,dist/*.zip
127+
makeLatest: true
128+
prerelease: ${{ steps.ctx.outputs.branch != 'stable' }}
129+
generateReleaseNotes: ${{ steps.ctx.outputs.branch == 'stable' }}
130+
131+
- if: inputs.artifact-action == 'build-release'
132+
name: Attest artifact
133+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
134+
with:
135+
subject-path: |
136+
dist/*.tar.xz
137+
dist/*.zip
138+
139+
container:
140+
if: github.repository_owner == 'jspaste' && inputs.image-action != 'none'
141+
name: Release container image
142+
runs-on: ubuntu-latest
143+
env:
144+
REGISTRY: ghcr.io
145+
146+
permissions:
147+
attestations: write
148+
id-token: write
149+
packages: write
150+
151+
steps:
152+
- name: Harden Runner
153+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
154+
with:
155+
egress-policy: audit
156+
157+
- name: Save context
158+
id: ctx
159+
env:
160+
CTX_BRANCH: ${{ github.head_ref || github.ref_name }}
161+
CTX_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
162+
run: |
163+
echo "branch=${CTX_BRANCH}" >>"$GITHUB_OUTPUT"
164+
echo "sha=${CTX_SHA}" >>"$GITHUB_OUTPUT"
165+
echo "sha_short=${CTX_SHA::7}" >>"$GITHUB_OUTPUT"
166+
167+
- name: Save tags
168+
id: tags
169+
env:
170+
BRANCH: ${{ steps.ctx.outputs.branch }}
171+
SHA: ${{ steps.ctx.outputs.sha }}
172+
SHA_SHORT: ${{ steps.ctx.outputs.sha_short }}
173+
run: |
174+
TIMESTAMP="$(date +%Y.%m.%d)"
175+
TIMESTAMP_ISO="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
176+
177+
if [[ "${BRANCH}" == "stable" ]]; then
178+
TAGS+=("latest")
179+
else
180+
TAGS+=("snapshot")
181+
fi
182+
183+
TAGS+=("${SHA}")
184+
TAGS+=("${TIMESTAMP}-${SHA_SHORT}")
185+
186+
echo "timestamp=${TIMESTAMP}" >>"$GITHUB_OUTPUT"
187+
echo "timestamp_iso=${TIMESTAMP_ISO}" >>"$GITHUB_OUTPUT"
188+
echo "version=${TIMESTAMP}-${SHA_SHORT}" >>"$GITHUB_OUTPUT"
189+
echo "list=${TAGS[*]}" >>"$GITHUB_OUTPUT"
190+
191+
- name: Checkout
192+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
193+
with:
194+
persist-credentials: false
195+
196+
- name: Build image
197+
id: build-image
198+
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13
199+
with:
200+
containerfiles: Dockerfile
201+
platforms: linux/amd64,linux/arm64
202+
image: ${{ github.repository }}
203+
layers: true
204+
oci: true
205+
tags: ${{ steps.tags.outputs.list }}
206+
extra-args: |
207+
--squash
208+
--identity-label=false
209+
--label=org.opencontainers.image.created=${{ steps.tags.outputs.timestamp_iso }}
210+
--label=org.opencontainers.image.revision=${{ steps.ctx.outputs.sha }}
211+
--label=org.opencontainers.image.version=${{ steps.tags.outputs.version }}
212+
213+
- if: inputs.image-action == 'build-release'
214+
name: Login to GHCR
215+
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
216+
with:
217+
username: ${{ github.repository_owner }}
218+
password: ${{ secrets.GITHUB_TOKEN }}
219+
registry: ${{ env.REGISTRY }}
220+
221+
- if: inputs.image-action == 'build-release'
222+
name: Push to GHCR
223+
id: push-image
224+
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8
225+
with:
226+
image: ${{ steps.build-image.outputs.image }}
227+
tags: ${{ steps.build-image.outputs.tags }}
228+
registry: ${{ env.REGISTRY }}
229+
230+
- if: inputs.image-action == 'build-release'
231+
name: Attest image
232+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
233+
with:
234+
subject-name: "${{ env.REGISTRY }}/${{ steps.build-image.outputs.image }}"
235+
subject-digest: ${{ steps.push-image.outputs.digest }}
236+
push-to-registry: false

0 commit comments

Comments
 (0)