Merge pull request #136 from meshcloud/feature/release2-0-0-beta1 #24
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: Release | |
on: | |
push: # trigger whenever a new version tag gets pushed https://github.community/t/how-to-run-github-actions-workflow-only-for-new-tags/16075/23 | |
tags: [v*] | |
jobs: | |
# We run the create-release action in a separate job to make the output available to the docker image and cli release jobs. | |
# This means upon running the create-release job, no tests have been executed. | |
create-release: | |
runs-on: ubuntu-latest | |
outputs: | |
upload-url: ${{ steps.create_release.outputs.upload_url}} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Set upload-url | |
run: echo "::set-output name=upload-url::${{ steps.create_release.outputs.upload_url }}" | |
# note: while repeated gradle builds may seem wasteful, the local docker build workflow is very handy so we do | |
# want to retain it. Unfortunately there's no easy way to extract the built jar from the image and publish that instead | |
release-service-broker-docker-image: # build and push docker image (this includes a gradle build running in docker) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Lowercase repository name # docker needs a lowercase name, see https://github.community/t/additional-function-s-lowercase-uppercase/140632 | |
run: | | |
echo "REPO=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV | |
- name: Create docker meta | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ghcr.io/meshcloud/unipipe-service-broker | |
tags: type=ref,event=tag | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
repository: ${{ env.REPO }} | |
push: ${{ startsWith(github.ref, 'refs/tags/') }} | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.meta.outputs.tags }} | |
release-service-broker-jar: # build self executable jar (another gradle build, this time locally) | |
runs-on: ubuntu-latest | |
needs: create-release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 11 | |
distribution: temurin | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@v3 | |
with: | |
arguments: build | |
- name: Upload Service Broker Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload-url }} | |
asset_path: ./build/libs/unipipe-service-broker-1.0.0.jar | |
asset_name: unipipe-service-broker.jar | |
asset_content_type: application/zip | |
release-cli: | |
# sadly, triggering on a successful build workflow and then downloading the artifacts from there is not yet | |
# possible with github actions, see https://github.com/actions/download-artifact/issues/3 | |
# if it was, we could avoid the rebuild and this step could look like this | |
# on: | |
# workflow_run: | |
# workflows: ["build"] | |
# branches: [refs/tags/v*] | |
# types: | |
# - completed | |
# instead, we now simply rebuild the whole thing in a single workflow and a single job | |
# not pretty but gets the job done | |
# if condition becomes relevant when cross workflow artifact downloads will be available | |
# if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
timeout-minutes: 3 # Generally our pipeline takes 1 minute to build everything. | |
runs-on: ubuntu-latest | |
needs: create-release | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: "~1.21" | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code | |
key: ${{ runner.os }}-deno # it seems there's no particular cache keying required | |
restore-keys: | | |
${{ runner.os }}-deno | |
- name: Build and Test | |
run: | | |
deno --version | |
deno info | |
cd cli | |
./build.sh | |
cd test | |
./all.sh ../bin/unipipe | |
# upload steps | |
- name: Upload unipipe-cli-x86_64-apple-darwin | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload-url }} | |
asset_path: ./cli/bin/unipipe-cli-x86_64-apple-darwin | |
asset_name: unipipe-cli-x86_64-apple-darwin | |
asset_content_type: application/octet-stream | |
- name: Upload unipipe-cli-x86_64-unknown-linux-gnu | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload-url }} | |
asset_path: ./cli/bin/unipipe-cli-x86_64-unknown-linux-gnu | |
asset_name: unipipe-cli-x86_64-unknown-linux-gnu | |
asset_content_type: application/octet-stream | |
- name: Upload unipipe-cli-x86_64-pc-windows-msvc.exe | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload-url }} | |
asset_path: ./cli/bin/unipipe-cli-x86_64-pc-windows-msvc.exe | |
asset_name: unipipe-cli-x86_64-pc-windows-msvc.exe | |
asset_content_type: application/octet-stream |