From aebfa706a673c5f9697ef6caad21144019a4eb6f Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Mon, 7 Oct 2019 17:32:15 +1030 Subject: [PATCH] ci: removed unneeded staging workflow and release script. Update main workflow --- .github/release.sh | 56 ------------------ .github/workflows/production.yml | 97 ++++++++++++++++++++++++++++---- .github/workflows/staging.yml | 36 ------------ 3 files changed, 86 insertions(+), 103 deletions(-) delete mode 100755 .github/release.sh delete mode 100644 .github/workflows/staging.yml diff --git a/.github/release.sh b/.github/release.sh deleted file mode 100755 index 10cbc052a..000000000 --- a/.github/release.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/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 $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 150d3491f..bd9faea2d 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -2,24 +2,21 @@ name: Production on: push: - branches: + branches: - master - jobs: - release: + test: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [10.x] - steps: - name: Checkout repo uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + - name: Add SSH deploy key run: | mkdir ~/.ssh/ @@ -32,17 +29,95 @@ jobs: ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts # Set correct permissions chmod 600 ~/.ssh/id_rsa + - name: Installing node deps run: npm install + + - name: Test + run: npm test + # uses: omgimalexis/ava-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Add SSH deploy key + run: | + mkdir ~/.ssh/ + # Add keys + echo "${{ secrets.GITHUB_READONLY_DEPLOY_KEY }}" > ~/.ssh/id_rsa + echo "${{ secrets.GITHUB_READONLY_DEPLOY_KEY_PUB }}" > ~/.ssh/id_rsa.pub + # Verifiy keys + ssh-keygen -l -f ~/.ssh/id_rsa.pub + # Add github.com to known hosts + ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + # Set correct permissions + chmod 600 ~/.ssh/id_rsa + + - name: Installing node deps + run: npm install + + - name: Lint + uses: omgimalexis/xo-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release: + runs-on: ubuntu-latest + + needs: [lint, test] + + strategy: + matrix: + node-version: [10.x] + + steps: + - name: Checkout repo + uses: actions/checkout@v1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Add SSH deploy key + run: | + mkdir ~/.ssh/ + # Add keys + echo "${{ secrets.GITHUB_READONLY_DEPLOY_KEY }}" > ~/.ssh/id_rsa + echo "${{ secrets.GITHUB_READONLY_DEPLOY_KEY_PUB }}" > ~/.ssh/id_rsa.pub + # Verifiy keys + ssh-keygen -l -f ~/.ssh/id_rsa.pub + # Add github.com to known hosts + ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + # Set correct permissions + chmod 600 ~/.ssh/id_rsa + + - name: Installing node deps + run: npm install + - name: Remove unneeded files run: npm run build + - name: Packing release run: npm pack - - name: Install hub - uses: geertvdc/setup-hub@master - - name: Create the release + + - name: Release to Github and s3 + uses: unraid/release-action@master env: GITHUB_USER: ${{ secrets.GITHUB_USER }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} - run: .github/release.sh + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_ACCESS_KEY_SECRET: ${{ secrets.AWS_ACCESS_KEY_SECRET }} + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml deleted file mode 100644 index 52eb8891c..000000000 --- a/.github/workflows/staging.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Staging - -on: [push] - -jobs: - lint: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [10.x] - - steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Add SSH deploy key - run: | - mkdir ~/.ssh/ - # Add keys - echo "${{ secrets.GITHUB_READONLY_DEPLOY_KEY }}" > ~/.ssh/id_rsa - echo "${{ secrets.GITHUB_READONLY_DEPLOY_KEY_PUB }}" > ~/.ssh/id_rsa.pub - # Verifiy keys - ssh-keygen -l -f ~/.ssh/id_rsa.pub - # Add github.com to known hosts - ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts - # Set correct permissions - chmod 600 ~/.ssh/id_rsa - - name: Installing node deps - run: npm install - - name: Linting - run: npm run lint - # Waiting on https://github.com/nektos/act/issues/74 and https://github.com/nektos/act/issues/76 - # uses: stoe/xo-action@v1.0.1 \ No newline at end of file