Skip to content

auto-release

auto-release #1802

Workflow file for this run

name: auto-release
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * *' # every day at 1 am
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Latest release is a pre-release, older than two weeks, with no open bugs.
run: |
RELEASES=$(curl --silent "https://api.github.com/repos/bruffridge/nasawds/releases")
IS_PRERELEASE=$(echo "$RELEASES" | jq -r '.[0].prerelease')
if [ "$IS_PRERELEASE" == false ]
then
echo "Latest release is not a pre-release, stop." >&2
exit 1
fi
PUBLISHED_AT=$(echo "$RELEASES" | jq -r '.[0].published_at')
NOW=$(date -uIseconds)
NOW=$(date --date="$NOW" +%s)
THEN=$(date --date="$PUBLISHED_AT" +%s)
DATE_DIFF=$((NOW-THEN))
if [ $DATE_DIFF -lt 1209600 ] # two weeks
then
echo "Latest release is less than two weeks old, stop."
exit 1
fi
ISSUES=$(curl --silent "https://api.github.com/repos/bruffridge/nasawds/issues?labels=bug")
OPEN_ISSUES=$(echo "$ISSUES" | jq '. | length')
if [ "$OPEN_ISSUES" -gt 0 ]
then
echo "There are open bugs, stop."
exit 1
fi
exit 0
- uses: actions/checkout@v3
with:
ref: develop
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: https://registry.npmjs.org/
- name: update npm package versioning
run: npm --no-git-tag-version version patch # updates package.json version number from 3.0.1-beta.0 to 3.0.1
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Bump npm version from beta prerelease to stable status
branch: develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
needs: update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: https://registry.npmjs.org/
- name: Merge develop into master
uses: robotology/[email protected]
with:
stable_branch: 'develop'
development_branch: 'master'
allow_ff: true
user_name: GitHub Actions
user_email: [email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: get package version
#https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#set-an-environment-variable-set-env
run: echo "RELEASE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
- run: npm ci
- run: npm run release
- run: echo "RELEASE_ASSET_PATH=$(find . -name "nasawds-*.zip")" >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.RELEASE_ASSET_PATH }}
tag: v${{ env.RELEASE_VERSION }}
body: |
No changes since last beta pre-release.
token: ${{ secrets.GITHUB_TOKEN }}
#https://github.com/actions/starter-workflows/blob/master/ci/npm-publish.yml
# remove .zip file
- run: rm -rf ${{ env.RELEASE_ASSET_PATH }}
- run: npm publish
env:
# https://stackoverflow.com/questions/57685065/how-to-set-secrets-in-github-actions
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}