-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(circleci-orb): initial setup for publishing dev-infra orb
Initial setup for publihsing an dev-infra orb.
- Loading branch information
1 parent
a53d820
commit acf5173
Showing
9 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This file will be generated by the publish script. | ||
packed-orb.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2.1 | ||
|
||
description: Angular Dev-Infra Private Orb | ||
|
||
display: | ||
home_url: 'https://angular.io' | ||
source_url: 'https://github.com/angular/dev-infra' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
ORB_NAME = "angular/dev-infra" | ||
|
||
ORB_VERSION = "dev:0.0.1" | ||
|
||
filegroup( | ||
name = "orb_generated_files", | ||
srcs = [ | ||
"//circleci-orb/scripts/rebase-on-target-branch:script", | ||
], | ||
) | ||
|
||
sh_binary( | ||
name = "publish", | ||
srcs = ["publish.sh"], | ||
args = [ | ||
ORB_NAME, | ||
ORB_VERSION, | ||
], | ||
data = [":orb_generated_files"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
description: Rebase PR on the target branch | ||
|
||
parameters: | ||
branch: | ||
type: string | ||
description: The `pipeline.git.branch` pipeline value. | ||
base_revision: | ||
type: string | ||
description: The `pipeline.git.base_revision` pipeline value. | ||
|
||
steps: | ||
- run: | ||
environment: | ||
CIRCLE_BASE_REVISION: << parameters.base_revision >> | ||
CIRCLE_BRANCH: << parameters.branch >> | ||
|
||
name: Rebasing PR on the target branch | ||
command: << include(../dist/bin/circleci-orb/scripts/rebase-on-target-branch/script.sh) >> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Helper rules for building CircleCI orbs with the help of Bazel.""" | ||
|
||
def nodejs_script_to_sh_script(name, output_file, bundle_file): | ||
"""Rule that takes a NodeJS script and wraps it into a Bash script. | ||
This is useful for inclusion in CircleCI `run` commands in Orbs because | ||
there cannot be an external NodeJS script file, or direct NodeJS `run` commands. | ||
""" | ||
native.genrule( | ||
name = name, | ||
srcs = [bundle_file], | ||
outs = [output_file], | ||
cmd = """ | ||
touch $@ | ||
echo '(cat <<"EOF" ' >> $@ | ||
cat $< >> $@ | ||
echo 'EOF' >> $@ | ||
echo ') | node' >> $@ | ||
""", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
orbName=${1} | ||
orbVersion=${2} | ||
|
||
cd ${BUILD_WORKSPACE_DIRECTORY}/circleci-orb | ||
|
||
# Pack the Orb (i.e. inline the built scripts etc.) | ||
circleci orb pack $PWD > $PWD/packed-orb.yml | ||
|
||
# Print the packed ORB for debugging/sanity check. | ||
cat $PWD/packed-orb.yml | ||
|
||
read -p "Do you want to proceed publishing? (press any key to continue)" -n 1 -r | ||
|
||
# Run the publish with the provided version and orb name. | ||
circleci orb publish $PWD/packed-orb.yml "${orbName}@${orbVersion}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
load("//tools:defaults.bzl", "esbuild", "ts_library") | ||
load("//circleci-orb:index.bzl", "nodejs_script_to_sh_script") | ||
|
||
package(default_visibility = ["//circleci-orb:__subpackages__"]) | ||
|
||
ts_library( | ||
name = "rebase-on-target-branch", | ||
srcs = ["index.ts"], | ||
deps = ["@npm//@types/node"], | ||
) | ||
|
||
esbuild( | ||
name = "bundle", | ||
entry_point = "index.ts", | ||
format = "iife", | ||
sourcemap = "inline", | ||
deps = [":rebase-on-target-branch"], | ||
) | ||
|
||
nodejs_script_to_sh_script( | ||
name = "script", | ||
bundle_file = ":bundle.js", | ||
output_file = "script.sh", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
const circleBaseRevision = process.env.CIRCLE_BASE_REVISION; | ||
const circleBranch = process.env.CIRCLE_BRANCH; | ||
|
||
console.error('Works', circleBaseRevision, circleBranch); |