From bde4cebd5d86d67302b11e4735ce2d14ec91a244 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 20 Mar 2022 14:54:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20publish-release.yml=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5tag=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-image.yml | 43 ++++++++++++++++++++++----- .github/workflows/publish-release.yml | 4 ++- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index df6cd2308..42c080c0e 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -2,6 +2,10 @@ name: Publish image on: workflow_dispatch: + inputs: + manualTag: + description: 'tag' + required: true release: types: [published] @@ -26,17 +30,35 @@ jobs: - name: Check the value run: | echo ${{ steps.step_one.outputs.hasToken }} - echo "GITHUB_REF: $GITHUB_REF" - echo "GITHUB_REF#refs/tags/: ${GITHUB_REF#refs/tags/}" + ##echo "GITHUB_REF: $GITHUB_REF" + ##echo "GITHUB_REF#refs/tags/: ${GITHUB_REF#refs/tags/}" + echo "github.event.release.tag_name: ${{ github.event.release.tag_name }}" + echo "github.event.inputs.manualTag: ${{ github.event.inputs.manualTag }}" + Publish2DockerHub: runs-on: ubuntu-latest needs: CheckDockerToken if: "contains(needs.CheckDockerToken.outputs.hasToken, 'true')" steps: + - + name: GetRepoTag + id: getRepoTag + run: | + RepoTag="" + if [ "${{ github.event.release.tag_name }}" ] ; then + RepoTag=${{ github.event.release.tag_name }} + fi + if [ "${{ github.event.inputs.manualTag }}" ] ; then + RepoTag=${{ github.event.inputs.manualTag }} + fi + echo "repo tag: $RepoTag" + echo "::set-output name=repoTag::$RepoTag" - name: Checkout uses: actions/checkout@v2 + with: + ref: ${{ steps.getRepoTag.outputs.repoTag }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -50,12 +72,17 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: GetTagName - id: getTag + name: GetDockerTagNames + id: getDockerTags run: | - DOCKER_IMAGE_TAG="zai7lou/bilibili_tool_pro:${GITHUB_REF#refs/tags/},zai7lou/bilibili_tool_pro:latest" - echo "docker image tag: $DOCKER_IMAGE_TAG" - echo "::set-output name=tag::$DOCKER_IMAGE_TAG" + DOCKER_IMAGE_TAG="zai7lou/bilibili_tool_pro:${{ steps.getRepoTag.outputs.repoTag }},zai7lou/bilibili_tool_pro:latest" + DOCKER_IMAGE_LATEST_TAG=",zai7lou/bilibili_tool_pro:latest" + if [ "${{ github.event.inputs.manualTag }}" ] ; then + DOCKER_IMAGE_LATEST_TAG="" + fi + DOCKER_IMAGE_TAGS=$DOCKER_IMAGE_TAG$DOCKER_IMAGE_LATEST_TAG + echo "docker image tag: $DOCKER_IMAGE_TAGS" + echo "::set-output name=dockerTags::$DOCKER_IMAGE_TAGS" - name: Build and push uses: docker/build-push-action@v2 @@ -63,4 +90,4 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - tags: ${{ steps.getTag.outputs.tag }} \ No newline at end of file + tags: ${{ steps.getDockerTags.outputs.dockerTags }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 85e84023b..71bfd9fff 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.version }} - name: Setup .NET uses: actions/setup-dotnet@v1 @@ -51,7 +53,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.event.inputs.version }} - release_name: BiliBiliTool-V${{ github.event.inputs.version }} + release_name: BiliBiliToolPro-V${{ github.event.inputs.version }} draft: true prerelease: false