Merge pull request #210 from umccr/enhancement/try-catch-json-output #37
Workflow file for this run
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 and Upload Release And Docker Container(s) | |
on: | |
push: | |
# Sequence of patterns matched against refs/tags | |
tags: | |
- 'v*' # Push events to matching v*, i.e v1.0, v20.15.10 etc | |
- 'pre-v*' # Push events to matching pre-v, i.ve pre-v1.0, pre-v20.15.10 | |
- 'latest' | |
jobs: | |
# First job | |
build_release: | |
name: Build Release Bundle | |
runs-on: ubuntu-latest | |
steps: | |
# Standard checkout step | |
- name: Checkout code | |
id: git_checkout | |
uses: actions/checkout@v2 | |
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
# Get tag name, from /ref/heads/<tag> to <tag> | |
- name: Get Tag Name | |
id: get_tag_name | |
run: echo "tag_name=$(basename ${{ github.ref }})" >> "${GITHUB_OUTPUT}" | |
# Is pre-release? | |
- name: Determine if this is a pre-release or not | |
id: is_prerelease | |
run: echo "prerelease=$(if [[ "${{ steps.get_tag_name.outputs.tag_name }}" == "pre"* || "${{ steps.get_tag_name.outputs.tag_name }}" == "dev" ]]; then echo true; else echo false; fi)" >> "${GITHUB_OUTPUT}" | |
# Build project | |
- name: Build project # This would actually build your project, using zip for an example artifact | |
uses: ./.github/actions/build-release | |
with: | |
git_tag: ${{ steps.get_tag_name.outputs.tag_name }} | |
# Create release zip file | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_tag_name.outputs.tag_name }} | |
release_name: release-${{ steps.get_tag_name.outputs.tag_name }} | |
draft: false | |
body: ${{ github.event.head_commit.message }} | |
prerelease: ${{ steps.is_prerelease.outputs.prerelease == 'true' }} | |
# Upload zip file as an asset | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# This pulls from the CREATE RELEASE step above, | |
# referencing it's ID to get its outputs object, which include a `upload_url`. | |
# See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release-${{ steps.get_tag_name.outputs.tag_name }}.zip | |
asset_name: release-${{ steps.get_tag_name.outputs.tag_name }}.zip | |
asset_content_type: application/zip | |
# Second job - can be run in parallel to building release | |
build_container: | |
name: Build Container | |
runs-on: ubuntu-latest | |
steps: | |
# Standard checkout step | |
- name: Checkout code | |
id: git_checkout | |
uses: actions/checkout@v3 | |
# Use qemu to perform multiplatform builds | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
# Use docker buildx to build multi-platform containers | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
use: true | |
install: true | |
config-inline: | | |
[worker.oci] | |
max-parallelism = 2 | |
# Log in to GitHub Container registry | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Build and push docker images | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
platforms: linux/amd64 | |
push: true | |
tags: ghcr.io/${{ github.repository }}:latest |