Upload Rakudo-Star to Rakudo.org #10
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: Upload Rakudo-Star to Rakudo.org | |
on: | |
schedule: # Allways later then the publishing of the Rakudo-Star releases at GH, see https://github.com/rakudo/star/blob/1149d43fd272661a1dbbcb9328200df24d1c2e81/.github/workflows/sync_latest_rakudo_release.yml#L11 | |
- cron: '55 1 * * 1,4' | |
workflow_dispatch: | |
env: | |
RKD_REVISION: "01" # Default build revision if RKD_STR_GH below has only a VERSION and not a revision (say, something like 202203-01 is expected) | |
DEBUG: 0 # Set this to 1 or anythin other then 0 (ZERO) for more debut output | |
jobs: | |
upload_star_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get GitHub's Rakudo Star and the Rakudo.org versions | |
id: rkd_v_check | |
run: | | |
RKD_STR_GH=$(curl -s https://raw.githubusercontent.com/rakudo/star/master/RELEASE | awk -F " ===> " '{print $1}') | |
if [[ ! "$RKD_STR_GH" =~ - ]]; then | |
echo ::set-output name=RKD_STR_GH_VERSION::$RKD_STR_GH | |
RKD_STR_GH="$RKD_STR_GH-$RKD_REVISION" | |
fi | |
RKD_STR_ORG_TMP=$(curl -s https://rakudo.org/dl/star/ | jq -r '.[] | select((.latest==1) and (.url|test("-win-x86_64-")) and (.url|test("checksum")|not)) | .url') | |
if [[ "$RKD_STR_ORG_TMP" =~ rakudo-star-([0-9]+.[0-9]+.?[0-9]?)-([0-9]+)- ]]; then | |
echo ::set-output name=RKD_STR_ORG_VERSION::${BASH_REMATCH[1]} | |
echo ::set-output name=RKD_STR_ORG_PATCH::${BASH_REMATCH[2]} | |
RKD_STR_ORG="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}" | |
else | |
echo "Couldn't get the RAKUDO.ORG Star version" | |
exit | |
fi | |
echo "\$RKD_STR_GH is \"$RKD_STR_GH\" and \$RKD_STR_ORG is \"$RKD_STR_ORG\"" | |
if [[ "$RKD_STR_GH" != "$RKD_STR_ORG" ]]; then | |
echo ::set-output name=publish::'true' | |
fi | |
- name: Prepare ssh config | |
id: ssh_config | |
if: steps.rkd_v_check.outputs.publish | |
run: | | |
if [[ ! -d ~/.ssh ]]; then mkdir -m 700 -p ~/.ssh; fi | |
echo "${{ secrets.ACTIONS_RAKUDO_ORG_CONFIG }}" | base64 -d > ~/.ssh/config | |
chmod 600 ~/.ssh/config | |
echo "${{ secrets.ACTIONS_RAKUDO_ORG_KNOWN_HOSTS }}" | base64 -d > ~/.ssh/known_hosts | |
chmod 0600 ~/.ssh/known_hosts | |
echo "${{ secrets.ACTIONS_RAKUDO_ORG_ED25519_PUB }}" | base64 -d > ~/.ssh/rakudo_id_ed25519.pub | |
chmod 644 ~/.ssh/rakudo_id_ed25519.pub | |
echo "${{ secrets.ACTIONS_RAKUDO_ORG_ED25519_PRIV }}" | base64 -d > ~/.ssh/rakudo_id_ed25519 | |
chmod 600 ~/.ssh/rakudo_id_ed25519 | |
echo ::set-output name=config::'true' | |
###- name: List my SSH stuff | |
### if: steps.ssh_config.outputs.config | |
### run: | | |
### echo "*** PWD is: $(pwd) ***" | |
### ls -laR ~/.ssh/* | |
### echo "*** show the ssh config file ***" | |
### cat ~/.ssh/config | |
### echo "*** show the ssh known_hosts file ***" | |
### cat ~/.ssh/known_hosts | |
### echo "*************************************" | |
- name: Get the Rakudo Star files | |
if: steps.ssh_config.outputs.config | |
run: | | |
mkdir ~/output && cd ~/output && pwd | |
for FILE in `curl -s https://api.github.com/repos/rakudo/star/releases/tags/${{steps.rkd_v_check.outputs.RKD_STR_GH_VERSION}} | jq -r ".assets[] | .browser_download_url"`; do | |
if [[ $DEBUG -ne 0 ]]; then echo "running curl -sL $FILE" ; fi | |
curl -sL $FILE -o $( basename $FILE ) | |
done | |
if [[ $DEBUG -ne 0 ]]; then | |
echo "BEFORE renaming of the downloaded Rakudo Start releases" | |
ls -laR | |
fi | |
for RKD in `ls -1`; do | |
[[ "$RKD" =~ ([a-zA-Z-]+)([0-9]+\.[0-9]+\.?[0-9]?)([-\.]{1})(.+)$ ]] | |
if [[ ! "${BASH_REMATCH[5]}" ]]; then | |
mv "$RKD" "${BASH_REMATCH[1]}${BASH_REMATCH[2]}-${{steps.rkd_v_check.outputs.RKD_STR_ORG_PATCH}}${BASH_REMATCH[3]}${BASH_REMATCH[4]}" | |
fi | |
done | |
if [[ $DEBUG -ne 0 ]]; then | |
echo "AFTER renaming of the downloaded Rakudo Start releases" | |
pwd | |
ls -laR | |
fi | |
- name: SCP Rakudo Star files from GitHub to RAKUDO.ORG | |
if: steps.ssh_config.outputs.config | |
run: | | |
if [[ $DEBUG -ne 0 ]]; then | |
echo "Show the Star files to copy over" | |
ls -laR ~/output/* | |
fi | |
### scp -vvv -o StrictHostKeyChecking=no ~/output/* rakudo.org:/home/rakudo.org/public_html/downloads/star | |
scp -o StrictHostKeyChecking=no ~/output/* rakudo.org:/home/rakudo.org/public_html/downloads/star | |
- name: Clean up SSH directory | |
if: steps.ssh_config.outputs.config | |
run: | | |
\rm -r ~/.ssh/* |