diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eff3a818f..7ede7d4cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,23 +6,7 @@ on: - main jobs: - changelog: - name: Create release changelog - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Generate changelog - if: startsWith(github.ref, 'refs/tags/') - run: npx changelogithub # or changelogithub@0.12 if ensure the stable result - env: - GITHUB_TOKEN: ${{secrets.MY_TOKEN}} - build: - needs: changelog strategy: matrix: platform: [ubuntu-latest] @@ -46,73 +30,27 @@ jobs: uses: actions/checkout@v2 with: ref: main - path: alist-web persist-credentials: false fetch-depth: 0 submodules: recursive - - name: Checkout dist repo - uses: actions/checkout@v2 - with: - repository: alist-org/web-dist - ref: main - path: web-dist - persist-credentials: false - fetch-depth: 0 - - - name: Replace version - if: startsWith(github.ref, 'refs/tags/') - run: | - version=$(git describe --abbrev=0 --tags) - sed -i -e "s/0.0.0/$version/g" alist-web/package.json - - name: Build run: | - cd alist-web pnpm install pnpm i18n pnpm build - cp -r dist ../ - cd .. env: CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} - - name: Copy dist and commit - run: | - cd web-dist - rm -rf dist - cp -r ../dist . - git add . - git config --local user.email "i@nn.ci" - git config --local user.name "Noah Hsu" - git commit --allow-empty -m "upload dist files" -a - cd .. - - - name: Upload dist files - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.MY_TOKEN }} - branch: main - directory: web-dist - repository: alist-org/web-dist - - - name: Publish npm - if: startsWith(github.ref, 'refs/tags/') - run: | - cd alist-web - echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc - pnpm publish --no-git-checks - cd .. - - - name: Compress dist files - if: startsWith(github.ref, 'refs/tags/') + - name: Compress dist run: | + mkdir compress tar -czvf compress/dist.tar.gz dist/* zip -r compress/dist.zip dist/* - - name: Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 + - name: Upload artifact + uses: actions/upload-artifact@v2 with: - files: compress/* \ No newline at end of file + name: alist-web + path: compress diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..505a5b57f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,91 @@ +name: release + +on: + push: + tags: + - '*' + + +jobs: + changelog: + name: Create release changelog + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Generate changelog + run: npx changelogithub # or changelogithub@0.12 if ensure the stable result + env: + GITHUB_TOKEN: ${{secrets.MY_TOKEN}} + + release: + needs: changelog + strategy: + matrix: + platform: [ubuntu-latest] + name: Release + runs-on: ${{ matrix.platform }} + steps: + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: "16" + registry-url: "https://registry.npmjs.org" + + - uses: pnpm/action-setup@v2.2.2 + name: Install pnpm + id: pnpm-install + with: + version: 7 + run_install: false + + - name: Checkout + uses: actions/checkout@v2 + with: + ref: main + path: alist-web + persist-credentials: false + fetch-depth: 0 + submodules: recursive + + - name: Checkout dist repo + uses: actions/checkout@v2 + with: + repository: alist-org/web-dist + ref: main + path: web-dist + persist-credentials: false + fetch-depth: 0 + + - name: Build + run: | + mv alist-web/release.sh . + bash release.sh + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + - name: Publish npm + run: | + cd alist-web + echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc + pnpm publish --no-git-checks + cd .. + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Upload dist files + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.MY_TOKEN }} + branch: main + directory: web-dist + repository: alist-org/web-dist + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: compress/* \ No newline at end of file diff --git a/package.json b/package.json index 6d136de2e..e365da9de 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,23 @@ { "name": "alist-web", "version": "0.0.0", - "description": "", + "author": { + "name": "Xhofe", + "email": "i@nn.ci", + "url": "https://www.nn.ci" + }, + "description": "The front end of Alist V3", + "repository": { + "type": "git", + "url": "git+https://github.com/alist-org/alist-web.git" + }, + "bugs": { + "url": "https://github.com/Xhofe/alist/issues" + }, + "files": [ + "dist" + ], + "homepage": "https://alist.nn.ci", "scripts": { "crowdin": "crowdin download", "i18n": "pnpm crowdin -b main --verbose && node ./scripts/i18n.mjs", diff --git a/release.sh b/release.sh new file mode 100644 index 000000000..ae677fed1 --- /dev/null +++ b/release.sh @@ -0,0 +1,27 @@ +# replace version +cd alist-web +version=$(git describe --abbrev=0 --tags) +sed -i -e "s/0.0.0/$version/g" package.json +cat package.json + +# build +pnpm install +pnpm i18n +pnpm build +cp -r dist ../ +cd .. + +# commit to web-dist +cd web-dist +rm -rf dist +cp -r ../dist . +git add . +git config --local user.email "i@nn.ci" +git config --local user.name "Noah Hsu" +git commit --allow-empty -m "upload $version dist files" -a +git tag -a $version -m "release $version" +cd .. + +mkdir compress +tar -czvf compress/dist.tar.gz dist/* +zip -r compress/dist.zip dist/* \ No newline at end of file