diff --git a/.github/workflows/docker.yml b/.github/workflows/build.yml similarity index 66% rename from .github/workflows/docker.yml rename to .github/workflows/build.yml index ce7e001f..bcf2d102 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,9 @@ on: tags: - '\d+\.\d+\.\d+' - '\d+\.\d+' + - '\d+\.\d+\.\d+-beta\d+' + - '\d+\.\d+-beta\d+' + - '\d+\.\d+-alpha\d+' jobs: test: @@ -27,6 +30,25 @@ jobs: mkdir -p config pytest + create-tag: + runs-on: ubuntu-latest + if: > + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'main' + needs: [test] + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Create tag + run: | + git checkout main + git config --global user.name "GitHub Action" + git config --global user.email " + git tag ${{ github.event.pull_request.title }} + git push --tags + build-webui: runs-on: ubuntu-latest needs: [test] @@ -58,36 +80,6 @@ jobs: path: webui/dist.zip - draft-release: - runs-on: ubuntu-latest - needs: [test] - if: > - github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'main' - steps: - - - name: Checkout code - uses: actions/checkout@v2 - - - name: download artifact - uses: actions/download-artifact@v3 - with: - name: dist - path: webui/dist.zip - - - name: Generate Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ github.event.pull_request.title }} - name: 🌟${{ github.event.pull_request.title }} - body: ${{ github.event.pull_request.body }} - draft: true - prerelease: false - files: | - webui/dist.zip - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - build-docker: runs-on: ubuntu-latest needs: [test, build-webui] @@ -106,18 +98,29 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 - - name: Docker metadata + - name: Docker metadata main id: meta uses: docker/metadata-action@v4 with: images: | - ghcr.io/estrellaxd/auto_bangumi estrellaxd/auto_bangumi ghcr.io/${{ github.repository }} tags: | type=semver,pattern={{version}} type=raw,value=latest + - name: Docker metadata dev + if: contains(github.ref, 'tags') && contains(github.ref, 'alpha') || contains(github.ref, 'beta') + id: meta-dev + uses: docker/metadata-action@v4 + with: + images: | + estrellaxd/auto_bangumi:dev + ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ github.ref_name }} + type=raw,value=dev-latest + - name: Login to DockerHub if: ${{ github.event_name == 'push' }} uses: docker/login-action@v2 @@ -150,3 +153,58 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }} + + release: + runs-on: ubuntu-latest + needs: [ create-tag, build-docker ] + steps: + + - name: Checkout code + uses: actions/checkout@v2 + + - name: download artifact + uses: actions/download-artifact@v3 + with: + name: dist + path: webui/dist.zip + + - name: Generate Release + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }} + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.pull_request.title }} + name: 🌟${{ github.event.pull_request.title }} + body: ${{ github.event.pull_request.body }} + draft: false + prerelease: false + files: | + webui/dist.zip + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + - name: Generate dev Release + if: ${{ github.event_name == 'push' && contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.ref_name }} + name: 🌙${{ github.ref_name }} + body: ${{ github.event.pull_request.body }} + draft: true + prerelease: true + files: | + webui/dist.zip + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + telegram: + runs-on: ubuntu-latest + needs: [ release ] + steps: + - name: send telegram message on push + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + message: | + New release: ${{ github.event.release.title }} + Link: ${{ github.event.release.html_url }} \ No newline at end of file diff --git a/.github/workflows/dev-latest.yml b/.github/workflows/dev-latest.yml deleted file mode 100644 index 3dbdf0c3..00000000 --- a/.github/workflows/dev-latest.yml +++ /dev/null @@ -1,139 +0,0 @@ -name: Build Docker(dev) - -on: - push: - tags: - - '\d+\.\d+\.\d+-beta\d+' - - '\d+\.\d+-beta\d+' - - '\d+\.\d+-alpha\d+' - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: "3.11" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f backend/requirements-dev.txt ]; then pip install -r backend/requirements-dev.txt; fi - pip install pytest - - name: Test - working-directory: ./backend/src - run: | - mkdir -p config - pytest - - build-webui: - runs-on: ubuntu-latest - needs: [test] - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: latest - run_install: true - - - name: Build - run: | - cd webui - pnpm build && zip -r dist.zip dist - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: dist - path: webui/dist.zip - - - dev-build: - runs-on: ubuntu-latest - needs: [test] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Create Version info - working-directory: ./backend/src - run: | - echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: | - estrellaxd/auto_bangumi - ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ github.ref_name }} - type=raw,value=dev-latest - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Login to ghcr.io - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.ACCESS_TOKEN }} - - - name: Download artifact - uses: actions/download-artifact@v2 - with: - name: dist - path: backend/dist.zip - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - file: Dockerfile - - generate_release: - runs-on: ubuntu-latest - needs: [dev-build] - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download artifact - uses: actions/download-artifact@v2 - with: - name: dist - path: webui/dist.zip - - - name: Generate Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ github.ref_name }} - name: 🌙${{ github.ref_name }} - draft: true - prerelease: true - files: webui/dist.zip - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index 19ea1750..00000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Create Pull Request - -on: - push: - tags: - - '\d+\.\d+\.\d+' - - '\d+\.\d+' - -jobs: - create-pull-request: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Generate pull request body - id: pr - run: | - echo "docs/changelog/${{ github.ref }}.md" - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.ACCESS_TOKEN }} - commit-message: 'chore: release ${{ github.ref }}' - title: '${{ github.ref }}' - body: | - ${{ steps.pr.outputs.body }} - branch: release/${{ github.ref }} - base: main - labels: release - draft: false - branch-suffix: timestamp - delete-branch: false \ No newline at end of file diff --git a/.github/workflows/telegram.yml b/.github/workflows/telegram.yml deleted file mode 100644 index c3a50131..00000000 --- a/.github/workflows/telegram.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Telegram Notification - -on: - release: - types: [published] - -jobs: - telegram: - runs-on: ubuntu-latest - steps: - - name: send telegram message on push - uses: appleboy/telegram-action@master - with: - to: ${{ secrets.TELEGRAM_TO }} - token: ${{ secrets.TELEGRAM_TOKEN }} - message: | - New release: ${{ github.event.release.title }} - Link: ${{ github.event.release.html_url }} \ No newline at end of file