From 8173b98b7aae5a54d2d57d537c3cfb4e70743cab Mon Sep 17 00:00:00 2001 From: Ravindra Marella Date: Sun, 4 Jul 2021 17:22:55 +0530 Subject: [PATCH] Add workflows to auto update, publish and release --- .gitattributes | 2 ++ .github/workflows/publish.yml | 21 ++++++++++++++ .github/workflows/release.yml | 16 +++++++++++ .github/workflows/update.yml | 52 +++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/update.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..205021e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Enforce Unix newlines +* text=auto eol=lf diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..15eb3c9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,21 @@ +name: Publish + +on: + push: + tags: + - v*.*.* + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b049b04 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +name: Release + +on: + push: + tags: + - v*.*.* + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Release + run: gh release create "${GITHUB_REF#refs/tags/}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..33a2b63 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,52 @@ +name: Auto Update + +on: + schedule: + - cron: '0 0 * * *' # Runs at 00:00 UTC every day + workflow_dispatch: + inputs: + force: + description: Force Update + default: '0' + dry: + description: Dry Run + default: '1' + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ssh-key: ${{ secrets.DEPLOY_KEY }} + - uses: git-actions/set-user@v1 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm ci + - name: Update + run: | + force="${{ github.event.inputs.force }}" + dry="${{ github.event.inputs.dry }}" + + # Check for Updates + if npm run check; then + if [ "$force" != "1" ]; then + exit 0 # exit if there are no changes + fi + elif [ $? -ge 4 ]; then + exit 1 # exit if icons are removed + fi + + # Update + npm run update + git commit -am 'Auto Update' || [ "$force" = "1" ] || exit 1 + + # Bump Version + npm version patch + + # Push + if [ "$dry" = "1" ]; then + exit 0 + fi + git push --follow-tags