From 470b6f1de4c006df80ad06d0de2c878d36e91f7d Mon Sep 17 00:00:00 2001 From: Artem <48178500+ElusAegis@users.noreply.github.com> Date: Sun, 15 Dec 2024 18:36:55 +0300 Subject: [PATCH] feat: activate only on tag push --- .github/workflows/update-ios-package.yml | 32 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-ios-package.yml b/.github/workflows/update-ios-package.yml index f00a3efc1..d80b42ed5 100644 --- a/.github/workflows/update-ios-package.yml +++ b/.github/workflows/update-ios-package.yml @@ -1,11 +1,10 @@ name: Build and Publish EZKL iOS SPM package on: - workflow_dispatch: - inputs: - tag: - description: "The tag to release" - required: true + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' jobs: build-and-update: @@ -17,6 +16,16 @@ jobs: - name: Checkout EZKL uses: actions/checkout@v3 + - name: Extract TAG from github.ref_name + run: | + # github.ref_name is provided by GitHub Actions and contains the tag name directly. + TAG="${{ github.ref_name }}" + echo "Original TAG: $TAG" + # Remove leading 'v' if present + NEW_TAG=${TAG#v} + echo "Stripped TAG: $NEW_TAG" + echo "TAG=$NEW_TAG" >> $GITHUB_ENV + - name: Install Rust (nightly) uses: actions-rs/toolchain@v1 with: @@ -104,9 +113,16 @@ jobs: - name: Tag the latest commit run: | cd ezkl-swift-package + source $GITHUB_ENV + # Tag the latest commit on the current branch - git tag ${{ github.event.inputs.tag }} - if ! git push origin ${{ github.event.inputs.tag }}; then - echo "::error::Failed to push tag '${{ github.event.inputs.tag }}' to ${{ env.EZKL_SWIFT_PACKAGE_REPO }}. Please ensure EZKL_PORTER_TOKEN has correct permissions." + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "Tag $TAG already exists locally. Skipping tag creation." + else + git tag "$TAG" + fi + + if ! git push origin "$TAG"; then + echo "::error::Failed to push tag '$TAG' to ${{ env.EZKL_SWIFT_PACKAGE_REPO }}. Please ensure EZKL_PORTER_TOKEN has correct permissions." exit 1 fi \ No newline at end of file