Skip to content

Merge remote-tracking branch 'upstream/master' #2

Merge remote-tracking branch 'upstream/master'

Merge remote-tracking branch 'upstream/master' #2

Workflow file for this run

name: Pocket per core ZIP files
on:
push:
branches:
- master
paths:
- pocket/raw/**
workflow_dispatch:
jobs:
list_cores:
runs-on: ubuntu-latest
outputs:
cores: ${{ steps.generate-matrix.outputs.cores }}
steps:
- uses: actions/checkout@v2
- id: generate-matrix
run: |
cd pocket/raw/Cores
CORES=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name)')
echo $CORES
echo "cores=${CORES}" >> $GITHUB_OUTPUT
zip_cores:
runs-on: ubuntu-latest
needs:
- list_cores
strategy:
fail-fast: false
matrix:
core: ${{ fromJSON(needs.list_cores.outputs.cores) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: core_name
run: |
string=${{ matrix.core }}
echo "longname=${{ matrix.core }}" >> $GITHUB_OUTPUT
prefix="jotego."
CORE=${string#"$prefix"}
echo "shortname=${CORE}" >> $GITHUB_OUTPUT
- id: files_and_folders
run: |
shortname=${{ steps.core_name.outputs.shortname }}
longname=${{ steps.core_name.outputs.longname }}
echo "${shortname}.txt" > file_list.txt
echo "Cores/${longname}" >> file_list.txt
echo "Presets/${longname}" >> file_list.txt
echo "Assets/${shortname}" >> file_list.txt
echo "Platforms/${shortname}.json" >> file_list.txt
echo "Platforms/_images/${shortname}.bin" >> file_list.txt
- name: echo files
run: cat file_list.txt
- name: get version
id: get_version
working-directory: ./pocket/raw
run: |
# Read the file "file_list.txt" and store the paths in an array
paths=()
while IFS= read -r line; do
paths+=("$line")
done < ../../file_list.txt
# Iterate through the paths and find the most recent git hash for each path
most_recent_hash=""
most_recent_timestamp=0
for path in "${paths[@]}"; do
# Get the most recent commit hash and timestamp
hash=$(git log -1 --pretty="format:%h" "$path")
timestamp=$(git log -1 --pretty="format:%at" "$path")
# Update the most recent hash and timestamp if necessary
if [ "$timestamp" -gt "$most_recent_timestamp" ]; then
most_recent_hash="$hash"
most_recent_timestamp="$timestamp"
fi
done
# Print the most recent git hash
echo "version=$most_recent_hash" >> $GITHUB_OUTPUT
- name: change version
working-directory: pocket/raw/Cores/${{ steps.core_name.outputs.longname }}
run: |
version=${{ steps.get_version.outputs.version }}
short_version=${version:0:7}
sed -i "s/noversion/$short_version/g" ./core.json
- name: make zip
working-directory: ./pocket/raw
run: |
zip -r ../${{ steps.core_name.outputs.longname }}.zip $(cat ../../file_list.txt)
- name: validate zip
run: npx openfpga-validator@latest check ./pocket/${{ steps.core_name.outputs.longname }}.zip
- uses: actions/upload-artifact@v3
with:
name: built_zips
path: ./pocket/${{ steps.core_name.outputs.longname }}.zip
commit_zips:
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- zip_cores
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: built_zips
path: pocket/zips
- run: ls pocket/zips
- name: commit zips
working-directory: pocket/zips
run: |
git config --global user.email "[email protected]"
git config --global user.name "The CI/CD Bot"
git add *
git commit -m "BOT: adding Pocket release files"
git push origin master