Skip to content

Commit

Permalink
Release using GitHub releases (#170)
Browse files Browse the repository at this point in the history
* ci: add special dependabot config for the runtime

* feat: make sure the PR is labeled

* chore: add gh configs

* chore: remove versions from package jsons

* ci: set versions during build

* chore: add nvmrc

* chore: discontinue CHANGELOG.md

* chore: remove the version check

* ci: check for versions

* fix: update packages / make build working again

* chore: propagate change to lockfile

* chore: remove workaround
  • Loading branch information
jkoenig134 authored Jun 5, 2024
1 parent d3d0408 commit 074abcf
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 103 deletions.
17 changes: 10 additions & 7 deletions .ci/buildAndPush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ if [ -z "$(which jq)" ]; then
exit 1
fi

PACKAGE_VERSION=$(jq .version -r package.json)
if [ -z "$VERSION" ]; then
echo "The environment variable 'VERSION' must be set."
exit 1
fi

case "$PACKAGE_VERSION" in
case "$VERSION" in
*-alpha*) BASE_TAG=alpha ;;
*-beta*) BASE_TAG=beta ;;
*-rc*) BASE_TAG=rc ;;
Expand All @@ -21,13 +24,13 @@ REPO="ghcr.io/nmshd/connector"

TAGS="-t $REPO:$BUILD_NUMBER -t $REPO:$COMMIT_HASH"

OUTPUT="$(DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $REPO:${PACKAGE_VERSION} 2>&1)" || true
OUTPUT="$(DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $REPO:${VERSION} 2>&1)" || true
if [[ $OUTPUT =~ (no such manifest: ghcr.io/nmshd/connector:) ]] || [[ $OUTPUT == "manifest unknown" ]]; then # manifest not found -> push
echo "pushing tag '${BASE_TAG}' and '${PACKAGE_VERSION}'"
echo "pushing tag '${BASE_TAG}' and '${VERSION}'"

TAGS="$TAGS -t $REPO:$BASE_TAG -t $REPO:$PACKAGE_VERSION"
TAGS="$TAGS -t $REPO:$BASE_TAG -t $REPO:$VERSION"
elif [[ $OUTPUT =~ (\{) ]]; then # manifest found -> ignore
echo "image '$PACKAGE_VERSION' already exists"
echo "image '$VERSION' already exists"
else # other error
echo $OUTPUT
fi
Expand All @@ -37,4 +40,4 @@ docker buildx build --push --provenance=true --sbom=true \
$TAGS \
--build-arg COMMIT_HASH=$COMMIT_HASH \
--build-arg BUILD_NUMBER=$BUILD_NUMBER \
--build-arg PACKAGE_VERSION=$PACKAGE_VERSION .
--build-arg VERSION=$VERSION .
9 changes: 6 additions & 3 deletions .ci/publishHelmChart.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
PACKAGE_VERSION=$(jq .version -r package.json)
if [ -z "$VERSION" ]; then
echo "The environment variable 'VERSION' must be set."
exit 1
fi

helm package --app-version $PACKAGE_VERSION --version $PACKAGE_VERSION ./helmChart
helm package --app-version $VERSION --version $VERSION ./helmChart

HELM_PATH="./connector-helm-chart-$PACKAGE_VERSION.tgz"
HELM_PATH="./connector-helm-chart-$VERSION.tgz"
REGISTRY="oci://ghcr.io/nmshd"

echo "deploying '$HELM_PATH' to oci REGISTRY '$REGISTRY'"
Expand Down
6 changes: 6 additions & 0 deletions .ci/publishNpm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
set -e
set -x

if [ -z "$VERSION" ]; then
echo "The environment variable 'VERSION' must be set."
exit 1
fi

cd packages/sdk
npm version $VERSION
npx enhanced-publish --if-possible --use-preid-as-tag
4 changes: 2 additions & 2 deletions .ci/testBuildingProductiveDockerImage.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
COMMIT_HASH=c
BUILD_NUMBER=b
PACKAGE_VERSION=p
VERSION=v

docker build --no-cache --progress=plain \
--tag ghcr.io/nmshd/connector:prod \
--build-arg COMMIT_HASH=$COMMIT_HASH \
--build-arg BUILD_NUMBER=$BUILD_NUMBER \
--build-arg PACKAGE_VERSION=$PACKAGE_VERSION .
--build-arg VERSION=$VERSION .
8 changes: 4 additions & 4 deletions .ci/writeBuildInformation.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -e

if [ -z "$PACKAGE_VERSION" ]; then
echo "The environment variable 'PACKAGE_VERSION' must be set."
if [ -z "$VERSION" ]; then
echo "The environment variable 'VERSION' must be set."
exit 1
fi

Expand All @@ -21,12 +21,12 @@ DATE=$(date -u --iso-8601=seconds)
TARGET_FILE="./dist/buildInformation.js"

echo "Writing the following properties into $TARGET_FILE"
echo " - VERSION: $PACKAGE_VERSION"
echo " - VERSION: $VERSION"
echo " - BUILD_NUMBER: $BUILD_NUMBER"
echo " - COMMIT_HASH: $COMMIT_HASH"
echo " - DATE: $DATE"

sed -i "s/{{version}}/$PACKAGE_VERSION/" $TARGET_FILE
sed -i "s/{{version}}/$VERSION/" $TARGET_FILE
sed -i "s/{{build}}/$BUILD_NUMBER/" $TARGET_FILE
sed -i "s/{{commit}}/$COMMIT_HASH/" $TARGET_FILE
sed -i "s/{{date}}/$DATE/" $TARGET_FILE
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Readiness checklist

- [ ] I added/updated tests.
- [ ] I ensured that the PR title is good enough for the changelog.
- [ ] I labeled the PR.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,28 @@ updates:
update-npm-dependencies:
patterns:
- "*"
exclude-patterns:
- "@nmshd/runtime"
reviewers:
- "jkoenig134"
- "sebbi08"
labels:
- "dependencies"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
groups:
update-npm-dependencies:
patterns:
- "@nmshd/runtime"
reviewers:
- "jkoenig134"
- "sebbi08"
labels:
- "runtime-upgrade"

##### Docker #####
- package-ecosystem: "docker"
directories:
Expand Down
21 changes: 21 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
changelog:
exclude:
labels:
- ci
- chore
- dependencies
- refactor
- test
categories:
- title: Breaking Changes
labels:
- breaking-change
- title: New Features
labels:
- enhancement
- title: Bug Fixes
labels:
- bug
- title: Other Changes
labels:
- "*"
17 changes: 17 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Check Pull Request

on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]

jobs:
validate-pr-label:
name: Validate the Pull Request's labels
runs-on: ubuntu-latest
steps:
- name: PR must be labeled
uses: jesusvasquez333/[email protected]
with:
disable-reviews: true
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: "breaking-change, bug, chore, ci, dependencies, documentation, enhancement, refactoring, test"
6 changes: 5 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish

on:
push:
branches: [main, release/**]
tags: "*"

jobs:
run-checks:
Expand All @@ -27,6 +27,7 @@ jobs:
- run: bash .ci/publishNpm.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ github.ref_name }}
needs: ["run-checks"]

publish-docker:
Expand All @@ -50,6 +51,7 @@ jobs:
env:
BUILD_NUMBER: ${{ github.run_number }}
COMMIT_HASH: ${{ github.sha }}
VERSION: ${{ github.ref_name }}
needs: ["run-checks"]

publish-helm:
Expand All @@ -65,4 +67,6 @@ jobs:
USER: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- run: bash .ci/publishHelmChart.sh
env:
VERSION: ${{ github.ref_name }}
needs: ["publish-docker"]
39 changes: 0 additions & 39 deletions .github/workflows/version-check.yml

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Discontinued

This changelog is discontinued in favor of the [GitHub Releases](https://github.com/nmshd/connector/releases)

## 3.11.4

- health checks now use `https_proxy` if set
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:22.2.0 as builder
ARG COMMIT_HASH
ARG BUILD_NUMBER
ARG PACKAGE_VERSION
ARG VERSION

WORKDIR /usr/app
COPY package.json package-lock.json tsconfig.json ./
Expand Down
Loading

0 comments on commit 074abcf

Please sign in to comment.