Setting output of a command as an environment variable

Suman Khanal's Avatar

Suman Khanal

23 Oct, 2021 10:54 AM

I want to clone a repo https://github.com/rakudo/rakudo and build a binary from it. While building binary, I want to tag the binary with the 5 digits of a hash of the last commit.

I want to set tag as the output of a command git ls-remote git://github.com/rakudo/rakudo.git refs/heads/master | cut -f 1 | cut -c1-5.
Here is my yaml file:

# Manually build and don't use MSVC's build process so disable it
build: off

platform:
  - x64

environment:
    APPVEYOR_BUILD_WORKER_IMAGE: macos-bigsur
    tag: TAG # TAG as the output of the command (git ls-remote git://github.com/rakudo/rakudo.git refs/heads/master | cut -f 1 | cut -c1-5)
    
install:
  - brew install zstd
  - git clone -b master --single-branch https://github.com/rakudo/rakudo.git
  - cd rakudo
  - perl Configure.pl --gen-moar --gen-nqp --backends=moar --relocatable --prefix=${APPVEYOR_BUILD_FOLDER}/rakudo-macos
  - make 
  - make install
  - export PATH=${APPVEYOR_BUILD_FOLDER}/rakudo-macos/bin:${APPVEYOR_BUILD_FOLDER}/rakudo-macos/share/perl6/site/bin:$PATH
  # note forward slash in the above line in macos
  - git clone -b master --single-branch https://github.com/ugexe/zef.git
  - cd zef 
  - raku -I. bin/zef install . && cd .. && rm -rf zef
  - zef install App::Mi6 App::Prove6 Linenoise
  - 7z a ${APPVEYOR_BUILD_FOLDER}/rakudo-${tag}.zip ${APPVEYOR_BUILD_FOLDER}/rakudo-macos/*

branches:
  only:
    - master
artifacts:
  - path: rakudo-$(tag).zip
    name: rakudo-macos

Any tips how to achieve this? To tag with few digits a a hash of the last commit (of the repo being built)?

Thank you,
Suman

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac