-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6375350
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Build new-api | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Build new-api | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build new-api | ||
uses: vmactions/freebsd-vm@v1 | ||
with: | ||
usesh: true | ||
release: 13.2 | ||
prepare: | | ||
pkg install -y node16 npm-node16 wget curl git gcc bash gawk gsed | ||
wget https://dl.google.com/go/go1.22.0.freebsd-amd64.tar.gz && tar -C /usr/local -xzf go1.22.0.freebsd-amd64.tar.gz && rm go1.22.0.freebsd-amd64.tar.gz | ||
ln -s /usr/local/go/bin/go /usr/local/bin/go | ||
run: | | ||
export LATEST_APP=$(wget -qO- https://api.github.com/repos/Calcium-Ion/new-api/tags | gawk -F '["v]' '/name/{print "v"$5;exit}') | ||
git clone -b $LATEST_APP https://github.com/Calcium-Ion/new-api | ||
cd new-api/web | ||
npm install | ||
git describe --tags > VERSION | ||
REACT_APP_VERSION=$(git describe --tags) npm run build | ||
cd .. | ||
go mod download | ||
go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o new-api | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@main | ||
with: | ||
name: new-api-freebsd | ||
path: | | ||
new-api/new-api | ||
- name: Generate release tag | ||
id: tag | ||
run: echo "release_tag=$(wget -qO- https://api.github.com/repos/Calcium-Ion/new-api/tags | gawk -F '["v]' '/name/{print "v"$5;exit}')" >> $GITHUB_OUTPUT | ||
|
||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag.outputs.release_tag }} | ||
files: | | ||
new-api/new-api | ||
- name: Delete workflow runs | ||
uses: Mattraks/delete-workflow-runs@v2 | ||
with: | ||
token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
retain_days: 1 | ||
keep_minimum_runs: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Check Updates | ||
|
||
on: | ||
schedule: | ||
- cron: '0 16 */1 * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: compare versions | ||
run: | | ||
export REMOTEVERSION=$(wget -qO- https://api.github.com/repos/Calcium-Ion/new-api/tags | gawk -F '["v]' '/name/{print "v"$5;exit}') | ||
export LOCALVERSION=$(curl --location --silent --fail --show-error "https://api.github.com/repos/k0baya/new-api-freebsd/releases/latest" | grep -oP '"tag_name":\s*"\K[^"]+') | ||
bash compare.sh | ||
- name: Trigger release | ||
if: ${{ env.SYNCED == 0 }} | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.PAT_TOKEN }} | ||
script: | | ||
await github.rest.actions.createWorkflowDispatch({ | ||
owner: 'k0baya', | ||
repo: 'new-api-freebsd', | ||
workflow_id: 'build.yml', | ||
ref: 'main' | ||
}) | ||
- name: Delete workflow runs | ||
if: ${{ env.SYNCED == 1 }} | ||
uses: Mattraks/delete-workflow-runs@v2 | ||
with: | ||
token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
retain_days: 1 | ||
keep_minimum_runs: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# New-API-FreeBSD | ||
Automatically build New-API (FreeBSD version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
if [[ "$LOCALVERSION" == "$REMOTEVERSION" ]]; then | ||
echo "SYNCED=1" >> $GITHUB_ENV | ||
else | ||
echo "SYNCED=0" >> $GITHUB_ENV | ||
fi |