diff --git a/.github/workflows/deploy-new-version.yml b/.github/workflows/deploy-new-version.yml index efb5a29..cfc56cd 100644 --- a/.github/workflows/deploy-new-version.yml +++ b/.github/workflows/deploy-new-version.yml @@ -17,20 +17,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Read version from file - run: | - CURRENT_VERSION=$(cargo pkgid --manifest-path fplus-http-server/Cargo.toml | cut -d'#' -f2) - echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV - - name: Install cargo-edit run: cargo install cargo-edit - name: Update version run: cargo set-version ${{ inputs.version }} - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Run cargo check run: cargo check @@ -39,20 +31,14 @@ jobs: git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - # - name: Commit version change - # run: | - # git commit -am "Update version to ${{ inputs.version }}" - # git push origin main + - name: Commit version change + run: | + git commit -am "Update version to ${{ inputs.version }}" + git push origin main call-release-workflow: - runs-on: ubuntu-latest - needs: [check-version, update-lock-and-commit] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: "Check build and push release" - uses: ./.github/workflows/release-new-version.yml - with: - version: ${{ inputs.version }} + needs: check-version + uses: ./.github/workflows/release-new-version.yml + with: + version: ${{ inputs.version }} + secrets: inherit diff --git a/.github/workflows/release-new-version.yml b/.github/workflows/release-new-version.yml index 0abf1b2..887313a 100644 --- a/.github/workflows/release-new-version.yml +++ b/.github/workflows/release-new-version.yml @@ -79,9 +79,6 @@ jobs: restore-keys: | ${{ runner.os }}-cargo-build- - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Run tests env: GH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }} @@ -97,9 +94,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -128,10 +122,11 @@ jobs: id: meta uses: docker/metadata-action@v5 with: + flavor: latest=false images: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }} tags: | - type=semver,pattern={{version}},value=v${{ inputs.version }} - type=ref,event=branch + type=semver,pattern={{version}},value=v${{ inputs.version }},enable=${{inputs.version != ''}} + type=raw,value={{branch}},enable=${{inputs.version != ''}} type=ref,event=pr,pattern={{branch}} - name: Build tag and push Docker image @@ -144,9 +139,9 @@ jobs: cache-to: type=gha,mode=max github-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Create and push tag - # if: inputs.version != '' - # run: | - # TAG_NAME="v${{ steps.meta.outputs.tags }}" - # git tag $TAG_NAME - # git push origin $TAG_NAME + - name: Create and push tag + if: ${{ github.ref == format('refs/heads/{0}', 'main') && inputs.version != '' }} + run: | + TAG_NAME="v${{ steps.meta.outputs.tags }}" + git tag $TAG_NAME + git push origin $TAG_NAME