Build new-api #6
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: Build new-api | |
uses: vmactions/freebsd-vm@v1 | |
with: | |
usesh: true | |
release: 13.2 | |
prepare: | | |
pkg install -y jq node20 npm-node20 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 | |
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
# echo '. $HOME/.cargo/env' >> ~/.bashrc | |
# . "$HOME/.cargo/env" | |
run: | | |
git clone -b main https://github.com/kuoihao/new-api | |
cd new-api/web | |
cp package.json package.json.bak && jq '.resolutions = {"rollup": "npm:@rollup/wasm-node"} | .overrides = {"rollup": "npm:@rollup/wasm-node"}' package.json.bak > package.json | |
npm install | |
git describe --tags > VERSION | |
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) 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 |