Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release Project

# This workflow is triggered manually from the Actions tab.
on:
workflow_dispatch:
inputs:
version:
description: 'The version to release'
required: true
type: string
sonatype_auto_publish:
description: 'Automatically publish the release to Sonatype'
type: boolean
default: false
required: true
create_tag:
description: 'Create a git tag'
type: boolean
default: true
required: true

jobs:
release:
runs-on: ubuntu-latest

permissions:
# required for creating git tags.
contents: write
# required by the bazel-contrib/publish-to-bcr action
# pull-requests: write

steps:
- name: Checkout current commit
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Maven and Bazel require Java to be available.
- name: Setup Java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
java-version: '21'
distribution: 'zulu'
java-package: jdk
# This will create the maven settings.xml on the fly
server-id: central
server-username: ${{ secrets.MAVEN_USERNAME }}
server-password: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Setup Bazel
uses: bazelbuild/setup-bazelisk@v3

- name: Publish to Sonatype
run: |
./maven/release_jsinterop_base.sh --version ${{ github.event.inputs.version }} --sonatype-auto-publish ${{ github.event.inputs.sonatype_auto_publish }}

- name: Create Git Tag
if: github.event.inputs.create_tag == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag -a "${{ github.event.inputs.version }}" -m "Release ${{ github.event.inputs.version }}"
git push origin "${{ github.event.inputs.version }}"
7 changes: 0 additions & 7 deletions maven/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,3 @@ common::cleanup_temp_files() {
rm -rf "${maven_wd}"
fi
}

common::create_and_push_git_tag() {
local lib_version="$1"
common::info "Creating git tag: ${lib_version}"
git tag -a "${lib_version}" -m "${lib_version} release"
git push origin "${lib_version}"
}
70 changes: 70 additions & 0 deletions maven/plugins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<classesDirectory>${classesDirectory}</classesDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-io</artifactId>
<!-- We need at least 3.5.1 to avoid https://github.com/codehaus-plexus/plexus-io/issues/109. Once we upgrade maven-jar-plugin itself to a version new enough to depend on 3.5.1 or higher, we can remove this override. -->
<version>3.5.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${javadocFile}</file>
<type>jar</type>
<classifier>javadoc</classifier>
</artifact>
<artifact>
<file>${sourcesFile}</file>
<type>jar</type>
<classifier>sources</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.7</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>${nexusUrl}</nexusUrl>
</configuration>
</plugin>
</plugins>
86 changes: 86 additions & 0 deletions maven/publish_to_sonatype.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# The script generates the open source artifacts for jsinterop.base and
# uploads them to sonatype.
set -euo pipefail

source "$(dirname "$0")/deploy.sh"

readonly MAVEN_ARTIFACT="base"
readonly BAZEL_ARTIFACT="base"
readonly BAZEL_PATH="java/jsinterop/base"


usage() {
echo ""
echo "$(basename $0): Build and deploy script for JsInterop Base."
echo ""
echo "$(basename $0) --version <version> [--no-deploy]"
echo " --help"
echo " Print this help output and exit."
echo " --version <version>"
echo " Maven version of the library to use for deploying to sonatype."
echo " --no-deploy"
echo " Skip the deployment part but build all artifacts."
echo " --sonatype-auto-publish"
echo " Publish the artifact on sonatype automatically after upload."
echo ""
}

parse_arguments() {
deploy_to_sonatype=true
lib_version=""
sonatype_auto_publish=false

while [[ $# -gt 0 ]]; do
case $1 in
--version )
shift
lib_version=$1
;;
--no-deploy )
deploy_to_sonatype=false
;;
--sonatype-auto-publish)
sonatype_auto_publish=true
shift
;;
--help )
usage
exit 0
;;
* )
common::error "unexpected option $1"
;;
esac
shift
done
}

main() {
parse_arguments "$@"

common::check_version_set
common::check_bazel_prerequisites
common::check_maven_prerequisites

common::build
common::deploy_to_sonatype
}

# Set the trap to cleanup temporary files on EXIT
trap common::cleanup_temp_files EXIT

main "$@"
70 changes: 70 additions & 0 deletions maven/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
# Copyright 2019 Google Inc. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script provides common function and variables used by other scripts to
# release specific projects.
readonly BAZEL_ROOT=$(pwd)

j2cl_utils::error() {
echo "Error: $1"
exit 1
}

j2cl_utils::info() {
echo "Info: $1"
}


#######################################
# Check if Bazel is installed and the script is run from the root of the Bazel
# repository.
# Globals:
# BAZEL
#######################################
j2cl_utils::check_bazel() {
if [ ! -f "MODULE.bazel" ]; then
error "This script must be run from the root of the Bazel repository (where MODULE.bazel exists)."
fi

# Check for Bazel or Bazelisk
if command -v bazelisk &> /dev/null; then
BAZEL="bazelisk"
elif command -v bazel &> /dev/null; then
BAZEL="bazel"
else
error "Neither Bazel nor Bazelisk is installed or in your PATH."
fi
}

#######################################
# Check if Maven is installed.
#######################################
j2cl_utils::check_maven() {
if ! command -v mvn &> /dev/null; then
error "Maven is not installed. Please install it."
fi

# TODO(dramaix): Do we still need this?
if ! command -v gpg2 &> /dev/null; then
error "gpg2 is not installed. Please install it."
fi
}

bazel_build() {
info "Building Bazel target: ${1}"
"${BAZEL}" build "${1}"
}


Loading