Create Release #350
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: | |
check-user-permissions: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check user permission | |
uses: stjude/proteinpaint/.github/actions/check-user-permissions@master | |
with: | |
BUILD_SECRET: ${{ secrets.BUILD_SECRET }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
INPUT_BUILD_SECRET: ${{ github.event.inputs.build_secret }} | |
publish-npm: | |
needs: check-user-permissions | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
timeout-minutes: 20 | |
outputs: | |
updated_rust: ${{ steps.version_bump.outputs.updated_rust }} | |
steps: | |
- 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: '20' | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@sjcrh' | |
- run: npm ci | |
- name: Run version bump | |
id: 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 | |
echo "::set-output name=branch::$BRANCH" | |
if [[ "$BRANCH" != "master" ]]; then | |
echo "::set-output name=draft::true" | |
echo "::set-output name=prerelease::true" | |
else | |
echo "::set-output name=draft::false" | |
echo "::set-output name=prerelease::false" | |
fi | |
echo "::set-output name=tag_name::$TAG" | |
./build/ci-npm-publish.sh "$UPDATED" | |
if [[ $UPDATED == *"rust"* ]]; then | |
echo "::set-output name=updated_rust::true" | |
else | |
echo "::set-output name=updated_rust::false" | |
fi | |
CHANGES="[CHANGELOG.md](https://github.com/stjude/proteinpaint/blob/master/CHANGELOG.md)" | |
echo "::set-output name=latest_release_changes::$CHANGES" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.version_bump.outputs.tag_name }} | |
release_name: ${{ steps.version_bump.outputs.tag_name }} | |
body: | | |
${{ steps.version_bump.outputs.latest_release_changes }} | |
draft: ${{ steps.version_bump.outputs.draft }} | |
prerelease: ${{ steps.version_bump.outputs.prerelease }} | |
rust-build: | |
if: needs.publish-npm.outputs.updated_rust == 'true' | |
needs: publish-npm | |
uses: ./.github/workflows/CD-rust-build.yml | |
upload-rust-assets: | |
needs: rust-build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload rust assets | |
uses: stjude/proteinpaint/.github/actions/upload-rust-assets@master | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-docker-no-new-rust-module: | |
if: needs.publish-npm.outputs.updated_rust == 'false' && github.event.inputs.include == 'npm packages + Docker image' | |
needs: publish-npm | |
runs-on: ubuntu-latest | |
steps: | |
- name: Publish docker image | |
uses: stjude/proteinpaint/.github/actions/publish-docker@master | |
with: | |
PAT: ${{ secrets.PAT }} | |
GITHUB_ACTOR: ${{ github.actor }} | |
publish-docker-with-new-rust-module: | |
if: github.event.inputs.include == 'npm packages + Docker image' | |
needs: upload-rust-assets | |
runs-on: ubuntu-latest | |
steps: | |
- name: Publish docker image | |
uses: stjude/proteinpaint/.github/actions/publish-docker@master | |
with: | |
PAT: ${{ secrets.PAT }} | |
GITHUB_ACTOR: ${{ github.actor }} |