From 7be0ca1626aa33da9fc62f7b0aa6269d274394ce Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Mon, 15 Mar 2021 18:48:01 +1300 Subject: [PATCH] ci(release): create index on release edit --- .github/workflows/package-index-release.yaml | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/package-index-release.yaml diff --git a/.github/workflows/package-index-release.yaml b/.github/workflows/package-index-release.yaml new file mode 100644 index 0000000..ec9d456 --- /dev/null +++ b/.github/workflows/package-index-release.yaml @@ -0,0 +1,34 @@ +on: + release: + type: [edited] + +jobs: + create_index: + if: github.ref == 'pkgs' + runs-on: ubuntu-latest + steps: + - name: "Download all release assets" + run: curl -s https://api.github.com/repos/engineer-man/piston/releases/39776531 | jq '.assets[].browser_download_url' -r | xargs curl -sLO + - name: "Generate index file" + run: | + echo "" > index + BASEURL=https://github.com/engineer-man/piston/releases/download/pkgs/ + for pkg in *.pkg.tar.gz + do + PKGFILE=$(basename $pkg) + PKGFILENAME=$(echo $PKGFILE | sed 's/\.pkg\.tar\.gz//g') + + PKGNAME=$(echo $PKGFILENAME | grep -oP '^\K.+(?=-)') + PKGVERSION=$(echo $PKGFILENAME | grep -oP '^.+-\K.+') + PKGCHECKSUM=$(sha256sum $PKGFILE | awk '{print $1}') + echo "$PKGNAME,$PKGVERSION,$PKGCHECKSUM,$BASEURL$PKGFILE" >> index + echo "Adding package $PKGNAME-$PKGVERSION" + done + - name: Upload index + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: index + tag: pkgs + overwrite: true + file_glob: true \ No newline at end of file