Skip to content

Commit

Permalink
Fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
k0baya committed Jul 11, 2024
1 parent 6375350 commit 5e3487a
Showing 1 changed file with 59 additions and 40 deletions.
99 changes: 59 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,70 @@ jobs:
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

- 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: |
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
cd ../..
- 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: 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.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 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: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
files: |
- 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
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 8

0 comments on commit 5e3487a

Please sign in to comment.