Create Release #93
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
name: "Create Release" | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
type: choice | |
description: Release type | |
options: | |
- patch | |
- minor | |
- major | |
- prepatch | |
- preminor | |
- premajor | |
- prerelease | |
include: | |
type: choice | |
description: Include | |
options: | |
- npm packages + Docker image | |
- npm packages only | |
build_secret: | |
type: string | |
description: Build secret | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
timeout-minutes: 20 | |
steps: | |
- name: Check secret | |
run: | | |
if [ "${{ github.event.inputs.build_secret }}" != "${{ secrets.BUILD_SECRET }}" ]; then | |
echo "Wrong build secret." | |
exit 1 | |
fi | |
- name: Check user permission | |
id: check | |
uses: scherermichael-oss/action-has-permission@master | |
with: | |
required-permission: write | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Exit if user doesn't have write permission | |
run: | | |
if [ "${{ steps.check.outputs.has-permission }}" = "false" ] | |
then | |
echo "Only users with write permission are allowed to execute this workflow manually." | |
exit 1 | |
fi | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PAT }} | |
- name: Fetch All Tags | |
run: git fetch --all --tags | |
# Setup .npmrc file to publish to GitHub Packages | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'npm' | |
node-version: '16' | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@sjcrh' | |
- run: npm ci | |
- name: Run version bump | |
run: | | |
exclude=""; | |
if [ "${{ github.event.inputs.include }}" = "npm packages only" ]; then | |
exclude="-x=container"; | |
fi | |
. ./build/ci-version-update.sh ${{ github.event.inputs.release_type }} -w $exclude | |
./build/ci-npm-publish.sh "$UPDATED" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }} | |
- name: Login to GitHub Container Registry | |
run: | | |
echo $CR_PAT | docker login ghcr.io -u stjude --password-stdin | |
env: | |
CR_PAT: ${{ secrets.PAT }} | |
- name: Build and Publish Docker Images | |
id: docker-publish | |
run: | |
sleep 90; | |
if [ "${{ github.event.inputs.include }}" = "npm packages + Docker image" ]; then | |
cd container; | |
./build2.sh -r "ghcr.io/stjude/" server; | |
TAG="$(node -p "require('./server/package.json').version")"; | |
HASH="$(git rev-parse --short HEAD)"; | |
docker push ghcr.io/stjude/ppserver:$TAG-$HASH; | |
docker push ghcr.io/stjude/ppserver:latest; | |
./build2.sh -r "ghcr.io/stjude/" full; | |
TAG="$(node -p "require('./full/package.json').version")"; | |
docker push ghcr.io/stjude/ppfull:$TAG-$HASH; | |
docker push ghcr.io/stjude/ppfull:latest; | |
echo "::set-output name=docker_version::$TAG-$HASH"; | |
else | |
echo "::set-output name=docker_version::NO_VERSION"; | |
fi | |
- name: get pp version | |
id: pp-version | |
uses: martinbeentjes/npm-get-version-action@main | |
- name: get front version | |
id: front-version | |
uses: martinbeentjes/npm-get-version-action@main | |
with: | |
path: front | |
- name: get server version | |
id: server-version | |
uses: martinbeentjes/npm-get-version-action@main | |
with: | |
path: server | |
- name: Run deploy action | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.PAT }} | |
repository: stjude/sj-pp | |
event-type: version-update | |
client-payload: '{"pp_version": "${{ steps.pp-version.outputs.current-version }}", "front_version": "${{ steps.front-version.outputs.current-version }}", "server_version": "${{ steps.server-version.outputs.current-version}}", "docker_version": "${{ steps.docker-publish.outputs.docker_version}}"}' |