From 7708bac87fc2824ff86719050a19b2860f80673a Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Mon, 30 Sep 2019 15:35:01 +0930 Subject: [PATCH] add new release script Signed-off-by: Alexis Tyler --- .github/release.sh | 56 ++++++++++++++++++++++++++++++++ .github/workflows/production.yml | 10 +++--- package.json | 5 +++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 .github/release.sh diff --git a/.github/release.sh b/.github/release.sh new file mode 100644 index 000000000..969c9cf76 --- /dev/null +++ b/.github/release.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# https://unix.stackexchange.com/a/9443/119653 +reverse () { + local line + if IFS= read -r line + then + reverse + printf '%s\n' "$line" + fi +} + +IS_TAG=$(git tag -l --points-at HEAD) +RELEASE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) +RELEASE=$(echo $RELEASE_TAG | awk -F- '{print $1}') +TIMESTAMP=$(date +%Y%m%d%H%M%S) +ROLLING_TAG="$RELEASE-rolling-$TIMESTAMP" +REPO=$(echo "${REPO#*/}") +ORG="unraid" + +# If tag then upload files for the tag +if [[ ! -z "$IS_TAG" ]]; then + # Compare to the last known semver version so we get the whole changelog + LAST_RELEASE=$(git tag --list --sort=v:refname | grep -v rolling | reverse | sed -n 2p) + RELEASE_NOTES=$(git log "$LAST_RELEASE...HEAD~1" --pretty=format:"- %s [\`%h\`](http://github.com/$ORG/$REPO/commit/%H)" --reverse) + + # Add title and body + printf "$RELEASE\n\n$RELEASE_NOTES" > release.md + # Release + if [[ $* == *--dry* ]]; then + echo "Type: Release" + echo "Tag: $RELEASE_TAG" + echo "Release: $LAST_RELEASE" + echo "----------" + cat release.md + else + hub release create -a unraid-$REPO-*.tgz -F release.md -p $RELEASE_TAG + fi +else + # Otherwise upload files to the rolling release + + # Create release notes + RELEASE_NOTES=$(git log "$RELEASE_TAG...HEAD" --pretty=format:"- %s [\`%h\`](http://github.com/$ORG/$REPO/commit/%H)" --reverse) + # Add title and body + printf "$ROLLING_TAG\n\n$RELEASE_NOTES" > release.md + # Release + if [[ $* == *--dry* ]]; then + echo "Type: Rolling" + echo "Tag: $ROLLING_TAG" + echo "Release: $RELEASE" + echo "----------" + cat release.md + else + hub release create -a unraid-$REPO-*.tgz -F release.md -p $ROLLING_TAG + fi +fi \ No newline at end of file diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index f31851e41..b86b0c211 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -37,9 +37,11 @@ jobs: run: npm run build - name: Packing release run: npm pack - - name: Uploading release to Github - uses: OmgImAlexis/upload-to-release@master - with: - args: unraid-graphql-api-*.tgz + - name: Install hub + uses: geertvdc/setup-hub@master + - name: Create the release env: + GITHUB_USER: ${{ secrets.GITHUB_USER }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + run: .github/release.sh diff --git a/package.json b/package.json index c27be59bf..9a3faa595 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,16 @@ "author": "Alexis Tyler (https://wvvw.me/)", "license": "UNLICENSED", "scripts": { + "commit": "npx git-cz", "dev": "STATES_CWD=$(pwd)/../core/test/fixtures/states CORE_CWD=$(pwd)/../core/ PLUGINS_CWD=$(pwd)/../plugins/ nodemon -e js,graphql --signal SIGINT index.js", "test": "exit 0", "lint": "exit 0", "build": "modclean --no-progress --run --path ." }, + "files": [ + "app/**/*", + "*.js" + ], "dependencies": { "@gridplus/docker-events": "^1.0.0", "@unraid/core": "unraid/core#c432714",