Build new-api #30
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
name: Build new-api | |
on: workflow_dispatch | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: Build new-api | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Clone Repo | |
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 | |
- name: Build Frontend | |
env: | |
CI: "" | |
run: | | |
cd new-api/web | |
npm install | |
REACT_APP_VERSION=$(git describe --tags) npm run build | |
cd ../.. | |
- name: Build Backend | |
uses: vmactions/freebsd-vm@v1 | |
with: | |
usesh: true | |
release: 13.2 | |
prepare: | | |
pkg install -y jq wget curl git gcc bash gawk gsed | |
wget https://dl.google.com/go/go1.23.4.freebsd-amd64.tar.gz && tar -C /usr/local -xzf go1.23.4.freebsd-amd64.tar.gz && rm go1.23.4.freebsd-amd64.tar.gz | |
ln -s /usr/local/go/bin/go /usr/local/bin/go | |
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
# echo '. $HOME/.cargo/env' >> ~/.bashrc | |
# . "$HOME/.cargo/env" | |
run: | | |
git config --global --add safe.directory /home/runner/work/new-api-freebsd/new-api-freebsd/new-api | |
cd new-api | |
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 |