Skip to content

Commit

Permalink
Reset to New-API branch
Browse files Browse the repository at this point in the history
  • Loading branch information
k0baya committed Mar 18, 2024
0 parents commit 6375350
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
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
39 changes: 39 additions & 0 deletions .github/workflows/compare.yml
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# New-API-FreeBSD
Automatically build New-API (FreeBSD version)
7 changes: 7 additions & 0 deletions compare.sh
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

0 comments on commit 6375350

Please sign in to comment.