diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f994391..af84438d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,18 +47,8 @@ jobs: go install src.techknowlogick.com/xgo@latest sudo apt install upx - - name: Build web - run: | - cd alist-web - yarn - yarn build - cd .. - - name: Build - run: | - cd alist - bash build.sh - cd .. + run: bash build.sh - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02fa517f..2edc72a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,18 +46,16 @@ jobs: go install src.techknowlogick.com/xgo@latest sudo apt install upx - - name: Build web - run: | - cd alist-web - yarn - yarn build - cd .. - - name: Build - run: | - cd alist - bash build.sh release - cd .. + run: bash build.sh release + + - name: Upload asserts files + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.MY_TOKEN }} + branch: cdn + directory: alist-web + repository: https://github.com/Xhofe/alist-web - name: Release uses: softprops/action-gh-release@v1 diff --git a/alist.go b/alist.go index f0936cbb..7aeb31de 100644 --- a/alist.go +++ b/alist.go @@ -30,7 +30,7 @@ func Init() { func main() { if conf.Version { - fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion:%s\n", conf.BuiltAt, conf.GoVersion, conf.GitAuthor, conf.GitCommit, conf.GitTag) + fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion: %s\n", conf.BuiltAt, conf.GoVersion, conf.GitAuthor, conf.GitCommit, conf.GitTag) return } Init() diff --git a/build.sh b/build.sh index 84180179..8a626f61 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,18 @@ #!/bin/bash +cd alist-web || exit +webCommit=$(git log --pretty=format:"%h" -1) +echo "web commit id: $webCommit" +yarn +if [ "$1" == "release" ]; then + yarn build --base="https://cdn.jsdelivr.net/gh/Xhofe/alist-web@cdn/v2/$webCommit" + mv dist/assets .. +else + yarn build +fi +cd .. + +cd alist appName="alist" builtAt="$(date +'%F %T %z')" goVersion=$(go version | sed 's/go version //') @@ -52,4 +65,17 @@ if [ "$1" == "release" ]; then do zip compress/$(echo $i | sed 's/\.[^.]*$//').zip "$i" done +fi +cd ../.. + +if [ "$1" == "release" ]; then + cd alist-web + git checkout cdn + mkdir "v2/$webCommit" + mv ../assets/ v2/$webCommit + git add . + git config --local user.email "i@nn.ci" + git config --local user.name "Xhofe" + git commit --allow-empty -m "upload $webCommit assets files" -a + cd .. fi \ No newline at end of file