diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90ae6ef..558b428 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,11 +1,11 @@ name: build - + on: workflow_dispatch: push: branches: - master - + jobs: build: runs-on: ubuntu-latest @@ -14,9 +14,14 @@ jobs: uses: actions/checkout@v4 - name: Install dependencies - run: | - sudo apt-get install -y raptor2-utils - pip install pyshacl + run: sudo apt-get install -y raptor2-utils + + - name: Build + run: scripts/combine | tee $GITHUB_STEP_SUMMARY - - name: Build and Validate - run: ./scripts/shacl + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: dist + folder: dist + single-commit: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5cfefaf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release +on: + push: + tags: '[2-9][0-9]\.[0-9][0-9]' +jobs: + create-release: + name: Create release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create-release.outputs.upload_url }} + steps: + - name: Changelog + id: changelog + uses: mikepenz/release-changelog-builder-action@v4 + with: + commitMode: true + configurationJson: | + { + "pr_template": "- #{{TITLE}}", + "template": "#{{UNCATEGORIZED}}" + } + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo apt-get install -y raptor2-utils + + - name: Build + id: build + run: | + scripts/combine | tee $GITHUB_STEP_SUMMARY + echo 'summary<> $GITHUB_OUTPUT + cat ${GITHUB_STEP_SUMMARY} >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + - name: Create Release + id: create-release + uses: softprops/action-gh-release@v2 + with: + body: | + ${{ steps.build.outputs.summary }} + ${{ steps.changelog.outputs.changelog }} + files: | + dist/snik.nt + dist/snik.ttl diff --git a/.github/workflows/shacl.yml b/.github/workflows/shacl.yml index 3b67f85..7b48788 100644 --- a/.github/workflows/shacl.yml +++ b/.github/workflows/shacl.yml @@ -1,11 +1,11 @@ name: SHACL - + on: workflow_dispatch: push: branches: - master - + jobs: shacl: runs-on: ubuntu-latest @@ -13,7 +13,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Build and Validate + - name: Validate uses: konradhoeffner/shacl@v1 with: data: | diff --git a/.gitignore b/.gitignore index ffd1cd1..6976b7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ .* dist +!.github diff --git a/scripts/combine b/scripts/combine index c2f5f91..ec10871 100755 --- a/scripts/combine +++ b/scripts/combine @@ -1,6 +1,5 @@ -#/bin/sh +#!/bin/sh # Combine all of SNIK into one file. -# "source scripts/combine" in CI so GITHUB_STEP_SUMMARY gets exported MYPATH=`dirname "$0"` MYPATH=`( cd "$MYPATH" && pwd )` @@ -8,14 +7,25 @@ DISTPATH=$MYPATH/../dist mkdir -p $DISTPATH cat $MYPATH/../*.ttl $MYPATH/../*.nt | rapper -i turtle -o turtle - http://www.snik.eu/ontology/ > $DISTPATH/snik.ttl cd $DISTPATH -GITHUB_STEP_SUMMARY="`wc -l snik.nt | cut -f1 -d ' '` triples \n\n" +rapper -i turtle -o ntriples snik.ttl > snik.nt +printf "`wc -l snik.nt | cut -f1 -d ' '` triples\n\n" +# awk supports decimal places if type awk > /dev/null 2>&1; then - GITHUB_STEP_SUMMARY+="| Filename | bytes | KiB | MiB | KB | MB |\n" - GITHUB_STEP_SUMMARY+="| -------- | ----- | --- | --- | -- | -- |\n" + echo "| Filename | bytes | KiB | MiB | KB | MB |" + echo "| -------- | ----- | --- | --- | -- | -- |" # "command ls" in case it is aliased to eza or something else, we need the exact ls output format - GITHUB_STEP_SUMMARY+=`LC_ALL=C command ls -l snik.* | awk '{printf("|%10s |%10s |%9s |%9s |%9s |%9s |\n", $9, $5, $5/1024, $5/1024^2, $5/1000, $5/1000^2)}'` + LC_ALL=C command ls -l snik.* | awk '{printf("|%11s |%10s |%9s |%9s |%9s |%9s |\n", $9, $5, $5/1024, $5/1024^2, $5/1000, $5/1000^2)}' fi - -printf "$GITHUB_STEP_SUMMARY" -export GITHUB_STEP_SUMMARY -cd .. +printf "\n## Rounded\n\n" +# bash has easier command substitution but only integers +echo "| Filename | triples | bytes | KiB | MiB | KB | MB |" +echo "| --------- | ------- | ----- | --- | --- | -- | -- |" +command ls -l snik.* | tr -s ' ' | cut -f5,9 -d ' ' | while read -r size filename; do + triples=$(rapper -i turtle -c "$filename" 2>&1 | grep -o "[0-9]*") + kb=$((size / 1000)) + mb=$((size / 1000000)) + kib=$((size / 1024)) + mib=$((size / 1024 / 1024)) + #echo "$size $filename" + printf "| %11s | %11s | %12s | %9s | %7s | %9s |%7s |\n" $filename $triples $size $kib $mib $kb $mb +done