From df55349bbbe37ecc03c2a767ef4b465dfd2c8c7c Mon Sep 17 00:00:00 2001 From: Cody Swendrowski Date: Sat, 11 Jul 2020 00:25:18 -0500 Subject: [PATCH] Add workflow --- .github/workflows/get-version.js | 2 ++ .github/workflows/main.yml | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/get-version.js create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/get-version.js b/.github/workflows/get-version.js new file mode 100644 index 0000000..d6e9677 --- /dev/null +++ b/.github/workflows/get-version.js @@ -0,0 +1,2 @@ +var fs = require('fs'); +console.log(JSON.parse(fs.readFileSync('module.json', 'utf8')).version); diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d9cef42 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,45 @@ +name: Module CI/CD + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # create a zip file with all files required by the module to add to the release + - run: zip -r ./module.zip module.json styles/ tabbed-chatlog.js + + # Get the version from 'module.json' + - name: Get Version + shell: bash + id: get-version + run: echo "::set-output name=version::$(node ./.github/workflows/get-version.js)" + + # Create a release for this specific version + - name: Create Release + id: create_version_release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true # set this to false if you want to prevent updating existing releases + name: Release ${{ steps.get-version.outputs.version }} + draft: false + prerelease: false + token: ${{ secrets.GITHUB_TOKEN }} + artifacts: './module.json,./module.zip' + tag: ${{ steps.get-version.outputs.version }} + + # Update the 'latest' release + - name: Create Release + id: create_latest_release + uses: ncipollo/release-action@v1 + if: endsWith(github.ref, 'master') + with: + allowUpdates: true + name: Latest + draft: false + prerelease: false + token: ${{ secrets.GITHUB_TOKEN }} + artifacts: './module.json,./module.zip' + tag: latest