diff --git a/.github/workflows/update-ios-package.yml b/.github/workflows/update-ios-package.yml index 3028b5b18..54c1fd9db 100644 --- a/.github/workflows/update-ios-package.yml +++ b/.github/workflows/update-ios-package.yml @@ -1,14 +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: @@ -20,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: @@ -107,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