ci: removed unneeded staging workflow and release script. Update main workflow

This commit is contained in:
Alexis Tyler
2019-10-07 17:32:15 +10:30
parent 3a4d7e3a76
commit aebfa706a6
3 changed files with 86 additions and 103 deletions

56
.github/release.sh vendored
View File

@@ -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

View File

@@ -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 }}

View File

@@ -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