Skip to content

Commit

Permalink
Support targetting a tag specified as input
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Apr 18, 2024
1 parent 6ee39f8 commit 9c81a5b
Showing 1 changed file with 68 additions and 30 deletions.
98 changes: 68 additions & 30 deletions .github/workflows/release-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,57 @@ name: Post Release Upload
# 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:
# Only to avoid some repetition
# TODO SHOULD BE LIKE THIS:
# FLAKE_REF: github:${{ github.repository }}/${{ github.ref_name }}
FLAKE_REF: github:${{ github.repository }}/6c57ef376ed84fa1d802c49e5aba0f0eac9d2d84
GH_TOKEN: ${{ github.token }}

jobs:
wait-for-hydra:
name: "Wait for hydra check-runs"
runs-on: ubuntu-latest
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
if: ${{ env.TARGET_TAG == '' }}
run: |
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
- name: Define FLAKE_REF
run: |
flake_ref="github:${{ github.repository }}/${{ env.TARGET_TAG }}"
echo "$flake_ref"
echo "FLAKE_REF=$flake_ref" >> "$GITHUB_ENV"
- name: Get specific check run status
timeout-minutes: 120
run: |
while [[ true ]]; do
# TODO SHOULD BE LIKE THIS:
# conclusion=$(gh api repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/check-runs --jq '.check_runs[] | select(.name == "ci/hydra-build:required") | .conclusion')
# TODO generalize
while true; do
# When supporting other architectures than Linux, this query should be adapted:
conclusion=$(gh api repos/$GITHUB_REPOSITORY/commits/6c57ef376ed84fa1d802c49e5aba0f0eac9d2d84/check-runs --jq '.check_runs[] | select(.name | test("ci/hydra-build:.*-linux.required")) | .conclusion')
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"
Expand Down Expand Up @@ -66,16 +90,27 @@ jobs:
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: |
nix flake metadata ${{ env.FLAKE_REF }}
nix flake metadata ${{ env.FLAKE_REF }} --json | jq -r '"LOCKED_URL=\(.url)"' >> "$GITHUB_OUTPUT"
nix flake metadata ${{ env.FLAKE_REF }} --json | jq -r '"LOCKED_URL=\(.url)"' >> "$GITHUB_ENV"
- name: Build
run: |
case ${{ matrix.arch }} in
linux)
nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#cardano-cli:exe:cardano-cli
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
Expand All @@ -90,31 +125,34 @@ jobs:
# tree result
# ;;
esac
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.arch }}
path: cardano-cli-*
retention-days: 1

# upload-assets:
# needs: [pull]
# name: "Upload Assets"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: ${{ github.sha }}-linux
# - uses: actions/download-artifact@v3
upload-assets:
needs: [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@v3
# - uses: actions/download-artifact@v4
# with:
# name: ${{ github.sha }}-win64
# - name: Release
# uses: input-output-hk/action-gh-release@v1
# with:
# draft: true
# files: |
# cardano-node-*-win64.zip
# cardano-node-*-macos.tar.gz
# cardano-node-*-linux.tar.gz
- name: Release
uses: input-output-hk/action-gh-release@v1
with:
draft: true
tag_name: ${{ env.TARGET_TAG }}
files: |
# TODO generalize
# cardano-cli-*-win64.zip
# cardano-cli-*-macos.tar.gz
cardano-cli-*-linux.tar.gz

0 comments on commit 9c81a5b

Please sign in to comment.