Release Upload #23
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: Post Release Upload | ||
# This makes it easy to get download release binaries built using | ||
# a github action for any tagged commit. | ||
# | ||
# This workflow builds and uploads the macOS, win64 and linux | ||
# binary packages as github assets. | ||
# | ||
# It uses `--builders "" --max-jobs 0` to ensure the assets are | ||
# from the IOG cache. | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
target_tag: | ||
description: 'The tag of the release to attach binaries to' | ||
default: '' | ||
required: false | ||
type: string | ||
release: | ||
types: | ||
- published | ||
push: | ||
tags: | ||
- '**' | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
jobs: | ||
wait_for_hydra: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
TARGET_TAG: ${{ steps.check_target_tag.TARGET_TAG }} | ||
FLAKE_REF: ${{ steps.define_flake_ref.FLAKE_REF }} | ||
steps: | ||
- name: Define target tag (1/2) | ||
if: ${{ inputs.target_tag != '' }} # If a tag was specified manually as input, use it | ||
run: | | ||
echo "TARGET_TAG=${{ inputs.target_tag }}" >> "$GITHUB_ENV" | ||
- name: Define target tag (2/2) | ||
if: ${{ inputs.target_tag == '' }} # If no tag was specified manually as input | ||
run: | | ||
current_tag=$(git tag --points-to HEAD | head -n 1) | ||
if [[ "$current_tag" != "" ]] | ||
then | ||
# The workflow runs on a commit that has a tag, use this tag | ||
echo "TARGET_TAG=$current_tag" >> "$GITHUB_ENV" | ||
fi | ||
- name: Check tag is defined | ||
id: check_target_tag | ||
run: | | ||
if [[ "${{ env.TARGET_TAG }}" == "" ]] | ||
then | ||
echo "The tag to build binaries for is undefined! Either:" | ||
echo "- This pipeline should run on a commit that has a tag" | ||
echo "- This pipeline should be executed manually and the tag to target should be specified with the 'target_tag' input" | ||
exit 1 | ||
fi | ||
echo "TARGET_TAG=${{ env.TARGET_TAG }}" >> "$GITHUB_OUTPUT" | ||
- name: Define FLAKE_REF | ||
id: define_flake_ref | ||
run: | | ||
flake_ref="github:${{ github.repository }}/${{ env.TARGET_TAG }}" | ||
echo "FLAKE_REF=$flake_ref" >> "$GITHUB_ENV" | ||
echo "FLAKE_REF=$flake_ref" >> "$GITHUB_OUTPUT" | ||
- name: Get specific check run status | ||
timeout-minutes: 120 | ||
run: | | ||
while true; do | ||
# When supporting other architectures than Linux, this query should be adapted: | ||
conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/${{ env.TARGET_TAG }}/check-runs" --jq '.check_runs[] | select(.name | test("ci/hydra-build:.*-linux.required")) | .conclusion') | ||
case "$conclusion" in | ||
success) | ||
echo "ci/hydra-build:required succeeded" | ||
exit 0;; | ||
failure) | ||
echo "ci/hydra-build:required failed" | ||
exit 1;; | ||
*) | ||
echo "ci/hydra-build:required pending. Waiting 30s..." | ||
sleep 30;; | ||
esac | ||
done | ||
pull: | ||
needs: [wait_for_hydra] | ||
strategy: | ||
matrix: | ||
arch: [linux] | ||
# TODO generalize | ||
# arch: [linux, macos, win64] | ||
name: "Download Asset from the Cache" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Nix with good defaults | ||
uses: input-output-hk/install-nix-action@v20 | ||
with: | ||
extra_nix_config: | | ||
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= | ||
substituters = https://cache.iog.io/ https://cache.nixos.org/ | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- name: LS | ||
run: | | ||
ls | ||
# - uses: actions/checkout@v4 | ||
# with: | ||
# fetch-depth: 0 | ||
# - name: LS | ||
# run: | | ||
# ls | ||
- name: Display flake metadata | ||
id: flake-metadata | ||
run: | | ||
Check failure on line 112 in .github/workflows/release-upload.yaml GitHub Actions / Post Release UploadInvalid workflow file
|
||
echo "${{ fromJSON(needs.wait_for_hydra.outputs }}" | ||
nix --version | ||
nix flake metadata "${{ needs.wait_for_hydra.outputs.FLAKE_REF }}" | ||
nix flake metadata "${{ needs.wait_for_hydra.outputs.FLAKE_REF }}" --json | jq -r '"LOCKED_URL=\(.url)"' >> "$GITHUB_ENV" | ||
- name: Build | ||
run: | | ||
case ${{ matrix.arch }} in | ||
linux) | ||
nix build --builders "" --max-jobs 0 ${{ env.LOCKED_URL }}#cardano-cli:exe:cardano-cli | ||
tree result/bin | ||
cp result/bin/cardano-cli cardano-cli-${{ matrix.arch }} | ||
;; | ||
# TODO generalize | ||
# Those need fixing, they have not been tested. But so far they are disabled, | ||
# because the only platform tested on hydra is Linux (see flake.nix) | ||
# macos) | ||
# nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#cardano-cli:exe:cardano-cli | ||
# tree result | ||
# ;; | ||
# win64) | ||
# nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#x86_64-w64-mingw32:cardano-cli:exe:cardano-cli | ||
# tree result | ||
# ;; | ||
esac | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ github.sha }}-${{ matrix.arch }} | ||
path: cardano-cli-* | ||
retention-days: 1 | ||
upload-assets: | ||
needs: [wait_for_hydra, pull] | ||
name: "Upload Assets" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ github.sha }}-linux | ||
# TODO generalize | ||
# - uses: actions/download-artifact@v4 | ||
# with: | ||
# name: ${{ github.sha }}-macos | ||
# - uses: actions/download-artifact@v4 | ||
# with: | ||
# name: ${{ github.sha }}-win64 | ||
- name: Release | ||
uses: input-output-hk/action-gh-release@v1 | ||
with: | ||
draft: true | ||
tag_name: ${{ needs.wait_for_hydra.outputs.TARGET_TAG }} | ||
files: | | ||
# TODO generalize | ||
# cardano-cli-*-win64.zip | ||
# cardano-cli-*-macos.tar.gz | ||
cardano-cli-*-linux.tar.gz |