Skip to content

Commit 979802e

Browse files
committed
Foof
1 parent c07200f commit 979802e

File tree

3 files changed

+56
-68
lines changed

3 files changed

+56
-68
lines changed

.github/workflows/release.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ on:
2222
description: 'The version to release'
2323
required: true
2424
type: string
25-
continue_if_release_exists:
26-
description: 'Continue the workflow even if the GitHub release already exists'
25+
continue_if_tag_exists:
26+
description: 'Continue the workflow even if the GitHub tag already exists'
2727
type: boolean
2828
required: true
2929
default: false
@@ -44,8 +44,9 @@ jobs:
4444
version: ${{ github.event.inputs.version }}
4545
publish_to_sonatype: false
4646
create_github_release: true
47-
continue_if_release_exists: ${{ github.event.inputs.continue_if_release_exists == 'true' }}
47+
continue_if_tag_exists: ${{ github.event.inputs.continue_if_tag_exists == 'true' }}
4848
publish_to_bcr: true
49+
bcr_bazel_test_command: "bazel test transpiler/javatests/com/google/j2cl/integration/java/emptyclass/..."
4950

5051
# Allow the reusable workflow to access the secrets.
5152
secrets: inherit

.github/workflows/release_common.yaml

Lines changed: 44 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ on:
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
198183
author_email: [email protected]
199184
permissions:

.github/workflows/release_prep.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/bin/bash
2-
# This file is used to prepare the release.
2+
# This file is used to prepare the githubrelease.
33
# It is not intended to be run directly but called from the github release
4-
# workflow.
4+
# workflow: bazel-contrib/.github/workflows/release_ruleset.yaml\
5+
set -euo pipefail
6+
57
tag="$1"
68
# The prefix is used to determine the directory structure of the archive. We strip the 'v'
79
# prefix from the version number.
810
directory="j2cl-${tag#v}"
911
archive="j2cl-${tag}.tar.gz"
1012

11-
git archive --format=tar --prefix=${directory}/ -o "${archive}" ${tag}
13+
git archive --format=tar --prefix=${directory}/ -o "${archive}" ${tag}
1214

13-
sha256=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
15+
sha256=$(shasum -a 256 "${archive}" | awk '{print $1}')
1416

1517
# The stdout of this program will be used as the top of the release notes for this release.
1618
cat << EOF
@@ -21,9 +23,9 @@ cat << EOF
2123
2. Add to your \`MODULE.bazel\` file:
2224
2325
\`\`\`starlark
24-
bazel_dep(
26+
bazel_dep(
2527
name = "j2cl",
26-
repo_name = "com_google_j2cl",
28+
repo_name = "com_google_j2cl",
2729
version = "${tag}")
2830
\`\`\`
2931

0 commit comments

Comments
 (0)