Skip to content

auto-prerelease

auto-prerelease #161

name: auto-prerelease
on:
workflow_dispatch:
schedule:
- cron: '0 0 */15 * *' # every 15 days at midnight
jobs:
pre-release:
runs-on: ubuntu-latest
steps:
# see if uswds version has changed since last nasawds release. if not, do nothing.
#checkout develop branch
- uses: actions/checkout@v3
with:
ref: develop
# https://github.com/actions/setup-node
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: https://registry.npmjs.org/
- run: npm install
# if npm outdated --parseable contains 'uswds:uswds' then exit code will be 0 and CI workflow will continue, otherwise exit code will be 1 and CI workflow will not continue.
# https://stackoverflow.com/questions/12375722/how-do-i-test-in-one-line-if-command-output-contains-a-certain-string
- run: npm outdated --parseable | grep -q @uswds/uswds
- run: npm update @uswds/uswds
- name: update npm package versioning
#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=$(npm --no-git-tag-version version prerelease --preid=beta)" >> $GITHUB_ENV
#run: echo "::set-env name=RELEASE_VERSION::$(npm --no-git-tag-version version prerelease --preid=beta)" # updates package.json version number from 3.0.0 to 3.0.1-beta.0
#https://github.com/ad-m/github-push-action
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Updated uswds package to latest version
branch: develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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: ${{ env.RELEASE_VERSION }}
prerelease: true
body: |
Changes in this Release
- uswds package updated to latest version
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 --tag beta
env:
# https://stackoverflow.com/questions/57685065/how-to-set-secrets-in-github-actions
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}