From 6317a8caaabc7cf88c721c6e2dc681f44fe33ae4 Mon Sep 17 00:00:00 2001 From: Ernesto Ojeda Date: Thu, 5 Oct 2023 13:30:59 -0700 Subject: [PATCH] ci: only release when semantic-release generates a new version Signed-off-by: Ernesto Ojeda --- .github/workflows/release.yml | 12 +++++++++--- .gitignore | 3 ++- .releaserc.json | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5ebaa04..299d43e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,20 +42,26 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # the .nextVersion file will be created by semantic-release - name: Get Next Version id: version run: | - git fetch --tags - echo "next=$(git tag | sort -r --version-sort | head -n1)" >> "$GITHUB_OUTPUT" + if [ -f .nextVersion ]; then + echo "next=$(cat .nextVersion)" >> "$GITHUB_OUTPUT" + else + echo "next=none" >> "$GITHUB_OUTPUT" + fi - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + if: ${{ steps.version.outputs.next != 'none' }} with: repository: open-amt-cloud-toolkit/e2e-testing ref: docker-release clean: true - token: ${{ secrets.PROJECTS_PAT }} + token: ${{ secrets.DOCKER_RELEASE_PAT }} - name: Create docker-release @ ${{ steps.version.outputs.next }} + if: ${{ steps.version.outputs.next != 'none' }} env: RELEASE_YAML: release/rpc-go.yml NEXT_VERSION: ${{ steps.version.outputs.next }} diff --git a/.gitignore b/.gitignore index cdceaf5a..4df6d695 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ coverage **/*.so **/*.dll **/*.h -**/launch.json \ No newline at end of file +**/launch.json +.nextVersion \ No newline at end of file diff --git a/.releaserc.json b/.releaserc.json index e3995020..c771970e 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -11,7 +11,8 @@ "@semantic-release/exec", { "prepareCmd": "docker build -t vprodemo.azurecr.io/rpc-go:v${nextRelease.version} .", - "publishCmd": "docker push vprodemo.azurecr.io/rpc-go:v${nextRelease.version}" + "publishCmd": "docker push vprodemo.azurecr.io/rpc-go:v${nextRelease.version}", + "verifyReleaseCmd": "echo v${nextRelease.version} > .nextVersion" } ] ]