3535 type : boolean
3636 required : false
3737 default : false
38+ bcr_bazel_test_command :
39+ description : ' The bazel test command to run before publishing to BCR'
40+ type : string
41+ required : false
3842 create_github_release :
3943 description : ' Create a GitHub release (which also creates a git tag)'
4044 type : boolean
4145 required : false
4246 default : false
43- continue_if_release_exists :
44- description : ' Continue the workflow even if the GitHub release already exists'
47+ continue_if_tag_exists :
48+ description : ' Continue the workflow even if the git tag already exists'
4549 type : boolean
4650 required : false
4751 default : false
@@ -111,80 +115,62 @@ jobs:
111115 SONATYPE_PASSWORD_TOKEN : ${{ secrets.SONATYPE_PASSWORD_TOKEN }}
112116 MAVEN_GPG_PASSPHRASE : ${{ secrets.MAVEN_GPG_PASSPHRASE }}
113117
114-
115- # create_github_release:
116- # if: ${{ inputs.create_github_release }}
117- # permissions:
118- # contents: write
119- # steps:
120- # - name: Checkout code
121- # uses: actions/checkout@v4
122-
123- # - name: Check if release exists
124- # id: check_release
125- # env:
126- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127- # run: |
128- # set +e # Do not exit on error. gh release view will return non-zero exit code if the release does not exist.
129- # gh release view ${{ inputs.version }} > /dev/null 2>&1
130- # if [ $? -eq 0 ]; then
131- # if [[ "${{ inputs.continue_if_release_exists }}" == "true" ]]; then
132- # echo "Release ${{ inputs.version }} already exists. Skipping release creation."
133- # echo "github_release_exists=true" >> $GITHUB_OUTPUT
134- # else
135- # echo "Error: Release ${{ inputs.version }} already exists."
136- # echo "Set 'continue_if_release_exists' to true if you want to continue with the exising release."
137- # exit 1
138- # fi
139- # else
140- # echo "Release ${{ inputs.version }} does not exist."
141- # echo "github_release_exists=false" >> $GITHUB_OUTPUT
142- # fi
143-
144- # - name: Build archive and Create Github Release
145- # if: ${{ steps.check_release.outputs.github_release_exists == 'false' }}
146- # env:
147- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148- # run: |
149- # set +x
150-
151- # echo "Archive built successfully."
152-
153- # echo "Creating GitHub release ${tag}"
154- # # This will also create a git tag if it does not exist.
155- # gh release create "${tag}" --generate-notes
156- # echo "GitHub release ${tag} created successfully."
157-
158- # echo "Uploading archive ${archive} to release ${tag}"
159- # gh release upload "${tag}" "${archive}"
160- # echo "Archive uploaded successfully."
161118 create_git_tag :
162119 runs-on : ubuntu-latest
163120 permissions :
164121 # Required for creating and pushing git tags.
165122 contents : write
166-
167123 steps :
168124 - name : Checkout current commit
169125 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
170-
171- - name : Create Git Tag
126+ - name : Check and Create Git Tag
172127 run : |
128+ TAG_NAME="${{ inputs.version }}"
129+ if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
130+ echo "Tag '$TAG_NAME' already exists."
131+ if [[ "${{ inputs.continue_if_tag_exists }}" == "true" ]]; then
132+ echo "Continuing workflow as 'continue_if_tag_exists' is true. Skipping tag creation."
133+ exit 0
134+ else
135+ echo "Error: Tag '$TAG_NAME' already exists and 'continue_if_tag_exists' is false. Aborting."
136+ exit 1
137+ fi
138+ fi
139+
173140 git config --local user.email "[email protected] " 174141 git config --local user.name "J2CL GitHub Bot"
175- git tag -a "${{ inputs.version }} " -m "Release ${{ inputs.version }} "
176- git push origin "${{ inputs.version }} "
142+ git tag -a "$TAG_NAME " -m "Release $TAG_NAME "
143+ git push origin "$TAG_NAME "
177144
178- release :
145+ run_tests :
146+ runs-on : ubuntu-latest
179147 needs : create_git_tag
148+ steps :
149+ - name : Checkout tagged commit
150+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
151+ with :
152+ ref : ${{ inputs.version }}
153+ - name : Setup Java
154+ uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
155+ with :
156+ java-version : ' 21'
157+ distribution : ' zulu'
158+ java-package : jdk
159+ - name : Setup Bazel
160+ uses : bazelbuild/setup-bazelisk@v3
161+ - name : Run CI tests
162+ run : ./build_test.sh "CI"
163+
164+ release :
165+ needs : run_tests
180166 if : ${{ inputs.create_github_release }}
181- uses :
bazel-contrib/.github/.github/ workflows/[email protected] 167+ uses :
bazel-contrib/.github/workflows/[email protected] 182168 with :
183169 prerelease : false
184170 release_files : ${{ github.event.repository.name }}-*.tar.gz
185171 tag_name : ${{ inputs.version }}
186- bazel_test_command : " bazel test transpiler/javatests/com/google/j2cl/integration/java/emptyclass/... "
187-
172+ bazel_test_command : ${{ inputs.bcr_bazel_test_command }}
173+ a
188174 publish_to_bcr :
189175 if : ${{ inputs.publish_to_bcr }}
190176 needs : release
@@ -193,7 +179,6 @@ jobs:
193179 tag_name : ${{ inputs.version }}
194180 registry_fork : j2cl-github-bot/bazel-central-registry
195181 attest : true
196- draft : true
197182 author_name : j2cl-github-bot
198183199184 permissions :
0 commit comments