Publish to npm using a GitHub action (#9588)
This commit is contained in:
parent
60005b35e4
commit
f2ee84b6a3
16
.github/actions/create-release-tag/Dockerfile
vendored
Normal file
16
.github/actions/create-release-tag/Dockerfile
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM debian:stable-slim
|
||||||
|
|
||||||
|
LABEL "name"="create-release-tag"
|
||||||
|
LABEL "version"="0.0.1"
|
||||||
|
|
||||||
|
LABEL "com.github.actions.name"="Create release tag"
|
||||||
|
LABEL "com.github.actions.description"="Creates a release tag equal to the last commit message"
|
||||||
|
LABEL "com.github.actions.icon"="tag"
|
||||||
|
LABEL "com.github.actions.color"="gray-dark"
|
||||||
|
|
||||||
|
ADD entrypoint.sh /action/entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x /action/entrypoint.sh
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends git
|
||||||
|
|
||||||
|
ENTRYPOINT ["/action/entrypoint.sh"]
|
||||||
14
.github/actions/create-release-tag/entrypoint.sh
vendored
Normal file
14
.github/actions/create-release-tag/entrypoint.sh
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# GitHub doesn't support running actions on new tags yet: we need to run it on the commit.
|
||||||
|
# For this reason, we can't be sure that the tag already exists. We can use the commit
|
||||||
|
# message to create the tag. If the tag already exists locally, they won't conflict because
|
||||||
|
# they have the same name and are on the same commit.
|
||||||
|
|
||||||
|
echo "INFO: Getting release version..."
|
||||||
|
tag_name=$(git log --oneline --format=%B -1 $GITHUB_SHA)
|
||||||
|
|
||||||
|
echo "INFO: Creating new tag..."
|
||||||
|
(git tag $tag_name $GITHUB_SHA) || echo "INFO: Tag already exists"
|
||||||
@ -5,16 +5,8 @@ set -e
|
|||||||
echo "INFO: Installing action dependencies..."
|
echo "INFO: Installing action dependencies..."
|
||||||
(cd /action; npm ci)
|
(cd /action; npm ci)
|
||||||
|
|
||||||
# GitHub doesn't support running actions on new tags yet: we need to run it on the commit.
|
|
||||||
# For this reason, we can't be sure that the tag already exists. We can use the commit
|
|
||||||
# message to create the tag. If the tag already exists locally, they won't conflict because
|
|
||||||
# they have the same name and are on the same commit.
|
|
||||||
echo "INFO: Getting release version..."
|
echo "INFO: Getting release version..."
|
||||||
# current_tag=$(git describe --abbrev=0 --tags $GITHUB_SHA)
|
current_tag=$(git describe --abbrev=0 --tags $GITHUB_SHA)
|
||||||
current_tag=$(git log --oneline --format=%B -1 $GITHUB_SHA)
|
|
||||||
|
|
||||||
echo "INFO: Creating new tag..."
|
|
||||||
(git tag $current_tag $GITHUB_SHA) || echo "INFO: Tag already exists"
|
|
||||||
|
|
||||||
last_tag=$(git describe --abbrev=0 --tags $current_tag^)
|
last_tag=$(git describe --abbrev=0 --tags $current_tag^)
|
||||||
echo "INFO: New version is $current_tag; last version is $last_tag."
|
echo "INFO: New version is $current_tag; last version is $last_tag."
|
||||||
|
|||||||
24
.github/main.workflow
vendored
24
.github/main.workflow
vendored
@ -1,6 +1,6 @@
|
|||||||
workflow "Release" {
|
workflow "Release" {
|
||||||
on = "push"
|
on = "push"
|
||||||
resolves = ["Trigger GitHub release"]
|
resolves = ["Trigger GitHub release", "Publish to npm"]
|
||||||
}
|
}
|
||||||
|
|
||||||
action "Trigger GitHub release" {
|
action "Trigger GitHub release" {
|
||||||
@ -12,8 +12,28 @@ action "Trigger GitHub release" {
|
|||||||
COMMIT_AUTHOR_EMAIL = "babel@hopeinsource.com"
|
COMMIT_AUTHOR_EMAIL = "babel@hopeinsource.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
needs = ["Create release tag"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "Publish to npm" {
|
||||||
|
uses = "docker://node:10"
|
||||||
|
secrets = ["NPM_TOKEN"]
|
||||||
|
|
||||||
|
runs = "make"
|
||||||
|
args = "publish"
|
||||||
|
|
||||||
|
env = {
|
||||||
|
CI = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
needs = ["Create release tag"]
|
||||||
|
}
|
||||||
|
|
||||||
# When GitHub Actions will support the "release" event for public
|
# When GitHub Actions will support the "release" event for public
|
||||||
# repositories, we won't need these checks anymore.
|
# repositories, we won't need this checks anymore.
|
||||||
|
action "Create release tag" {
|
||||||
|
uses ="./.github/actions/create-release-tag"
|
||||||
|
|
||||||
needs = [
|
needs = [
|
||||||
"Is version commit",
|
"Is version commit",
|
||||||
"On master branch",
|
"On master branch",
|
||||||
|
|||||||
7
Makefile
7
Makefile
@ -127,11 +127,12 @@ prepublish-build:
|
|||||||
make clone-license
|
make clone-license
|
||||||
|
|
||||||
prepublish:
|
prepublish:
|
||||||
git pull --rebase
|
make bootstrap-only
|
||||||
make prepublish-build
|
make prepublish-build
|
||||||
make test
|
make test
|
||||||
|
|
||||||
new-version:
|
new-version:
|
||||||
|
git pull --rebase
|
||||||
./node_modules/.bin/lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/standalone,@babel/preset-env-standalone"
|
./node_modules/.bin/lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/standalone,@babel/preset-env-standalone"
|
||||||
|
|
||||||
# NOTE: Run make new-version first
|
# NOTE: Run make new-version first
|
||||||
@ -139,9 +140,11 @@ publish: prepublish
|
|||||||
./node_modules/.bin/lerna publish from-git --require-scripts
|
./node_modules/.bin/lerna publish from-git --require-scripts
|
||||||
make clean
|
make clean
|
||||||
|
|
||||||
bootstrap: clean-all
|
bootstrap-only: clean-all
|
||||||
yarn --ignore-engines
|
yarn --ignore-engines
|
||||||
./node_modules/.bin/lerna bootstrap -- --ignore-engines
|
./node_modules/.bin/lerna bootstrap -- --ignore-engines
|
||||||
|
|
||||||
|
bootstrap: bootstrap-only
|
||||||
make build
|
make build
|
||||||
cd packages/babel-plugin-transform-runtime; \
|
cd packages/babel-plugin-transform-runtime; \
|
||||||
node scripts/build-dist.js
|
node scripts/build-dist.js
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user