Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Publish fixes & polish #88

Merged
merged 1 commit into from
Sep 7, 2022
Merged
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
42 changes: 24 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,41 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
# To publish from a release or feature branch, remove the ref == condition below
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|| (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/'))
|| (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
outputs:
FULL_VERSION: ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
DIST_TAG: ${{ steps.guess-build-metadata.outputs.DIST_TAG }}
TARGET_VERSION: ${{ steps.check-version.outputs.TARGET_VERSION }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: https://npm.pkg.github.com
- run: |-
- name: Check version number is same between tag, library, and/or release
id: check-version
run: |-
if [[ ${{ github.ref }} = refs/heads/release/* ]]; then
scripts/check-version-is.sh "${GITHUB_REF##*release/}"
elif [[ ${{ github.ref }} = refs/tags/v* ]]; then
scripts/check-version-is.sh "${GITHUB_REF_NAME#v}"
else
scripts/check-version-is.sh
fi
- name: Check version number is same between tag, library, and/or release
id: guess-build-metadata
run: |-
echo "::set-output name=FULL_VERSION::$(.github/workflows/gh-semver.sh)"
echo "::set-output name=DIST_TAG::$(.github/workflows/guess-dist-tag.sh)"
- run: make test
- run: make doc
- run:
.github/workflows/publish-to.sh $(.github/workflows/gh-semver.sh)
$(.github/workflows/guess-dist-tag.sh)
- run: echo "::notice file=lib/package.json::Will be published to GitHub Packages as $(.github/workflows/guess-dist-tag.sh) with version=[$(.github/workflows/guess-dist-tag.sh)]"
- run: >-
.github/workflows/publish-to.sh ${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
${{ steps.guess-build-metadata.outputs.FULL_VERSION }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: trigger xtest
Expand All @@ -207,28 +222,19 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
environment: npmjs
needs: deliver-ghp
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main')
|| (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/'))
|| (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/'))
needs: deliver-ghp
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: |-
if [[ ${{ github.ref }} = refs/heads/release/* ]]; then
scripts/check-version-is.sh "${GITHUB_REF##*release/}"
elif [[ ${{ github.ref }} = refs/tags/v* ]]; then
scripts/check-version-is.sh "${GITHUB_REF_NAME#v}"
else
scripts/check-version-is.sh
fi
- run: make test
- run:
.github/workflows/publish-to.sh $(.github/workflows/gh-semver.sh)
$(.github/workflows/guess-dist-tag.sh)
- run: >-
.github/workflows/publish-to.sh ${{ needs.deliver-ghp.outputs.FULL_VERSION }}
${{ needs.deliver-ghp.outputs.FULL_VERSION }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/gh-semver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# git state and 'target' semver found in its package.
#
# Examples:
#
#
# Main branches build beta builds:
# ```
# package.version = 1.2.3
Expand All @@ -14,7 +14,7 @@
# ----
# 1.2.3-beta.256+bad.decaf
# ```
#
#
# Release branches build rc builds:
# ```
# package.version = 1.2.3
Expand All @@ -25,7 +25,7 @@
# ----
# 1.2.3-rc.256+bad.decaf
# ```
#
#
# Tags go to release:
# ```
# package.version = 1.2.3
Expand All @@ -36,7 +36,7 @@
# 1.2.3
# ```
#
#
#
set -euo pipefail

SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/publish-to.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ cd ../cli
npm --no-git-tag-version --allow-same-version version "$v" --tag "$t"
npm uninstall "@opentdf/client"
npm install "@opentdf/client@$v"
npm publish
npm publish --access public

if [[ "$GITHUB_STEP_SUMMARY" ]]; then
echo "### Published ${v}" >>$GITHUB_STEP_SUMMARY
fi
8 changes: 6 additions & 2 deletions scripts/check-version-is.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ lib_version="$(cd lib && node -p "require('./package.json').version")"
expected_version="${1:-$lib_version}"

if ! grep -Fxq "version=${expected_version}" "Makefile"; then
echo "Makefile missing version line [version=${expected_version}]"
echo "::error file=Makefile::Makefile missing version line [version=${expected_version}]"
exit 1
fi

for x in lib cli web-app; do
sub_version="$(cd $x && node -p "require('./package.json').version")"
if [[ $expected_version != "$sub_version" ]]; then
echo "${x} has incorrect version [${sub_version}], expected [${expected_version}]"
echo "::error file=${x}/package.json::Incorrect version [${sub_version}], expected [${expected_version}]"
exit 1
fi
done

if [[ "${GITHUB_ACTION}" ]]; then
echo "::set-output name=TARGET_VERSION::$expected_version"
fi