From 391eb6f751e35c8410308cc290ea1cb39bfc5e90 Mon Sep 17 00:00:00 2001 From: AZMCode Date: Mon, 17 Aug 2020 14:16:31 -0400 Subject: [PATCH 1/4] Excluded files and script rename --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d64e2ef..fb68760 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "prepare": "npm run build", "test": "mocha --timeout 60000 -r ts-node/register src/Tests/Tests.*.ts", "lint": "eslint '*/*.ts' --quiet --fix", - "build": "tsc", + "build:tsc": "tsc", "build:docs": "typedoc", "example": "npx ts-node Example/example.ts", "browser-decode": "npx ts-node src/BrowserMessageDecoding.ts" @@ -30,6 +30,9 @@ "repository": { "url": "git@github.com:adiwajshing/baileys.git" }, + "files": [ + "./lib/**/*.js" + ], "dependencies": { "@adiwajshing/keyed-db": "^0.1.1", "curve25519-js": "0.0.4", From 4acbae8cad9a9115a8f5c8bacc21a4daac1d5c0e Mon Sep 17 00:00:00 2001 From: AZMCode Date: Mon, 17 Aug 2020 15:18:35 -0400 Subject: [PATCH 2/4] * Added build:all script * Reworked other commands * Added main workflow (main.yml) * Builds once to both test and publish through the baileysBuilt artifact (Only lib, docs and package.json) * Using npm install instead of npm ci due to lockfiles not being included with the repo. Might cause a small slowdown in building --- .github/workflows/main.yml | 115 +++++++++++++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..34fcb98 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,115 @@ +name: CI + +on: ["push"] +jobs: + Build: + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout Commit + uses: actions/checkout@v2 + + - name: Parsing Package Info + id: packageInfo + run: | + echo "::set-output name=package-name::$(jq -r .name package.json)" + echo "::set-output name=package-version::$(jq -r .version package.json)" + echo "::set-output name=commit-msg::$(git log -1 --pretty=%B)" + + - name: Setup Node.js environment + uses: actions/setup-node@v2.1.1 + + - name: Install Dependencies + run: npm install + + - name: Build + run: npm run build:all + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v2.1.4 + with: + name: baileysBuilt + path: | + docs/**/* + lib/**/* + package.json + + Publish-Docs: + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + runs-on: ubuntu-latest + needs: Build + + steps: + + - name: Download Build Artifact + uses: actions/download-artifact@v2.0.5 + with: + # Artifact name + name: baileysBuilt + # Destination path + path: ${{ github.workspace }} + + - name: Publish to Pages + uses: crazy-max/ghaction-github-pages@v2 + with: + target_branch: gh-pages + if-no-files-found: error + build_dir: docs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + Publish-Package: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + needs: Build + steps: + - name: Download Build Artifact + uses: actions/download-artifact@v2.0.5 + with: + name: baileysBuilt + path: ${{ github.workspace }} + + - name: Setup Node.js environment + uses: actions/setup-node@v2.1.1 + + - name: Create Release + id: releaseCreate + continue-on-error: true + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # The name of the tag. This should come from the webhook payload, `github.GITHUB_REF` when a user pushes a new tag + tag_name: v${{ needs.Build.outputs.package-version }} + # The name of the release. For example, `Release v1.0.1` + release_name: v${{needs.Build.outputs.package-version}} + # Text describing the contents of the tag. + body: ${{needs.Build.outputs.commit-msg}} + # `true` to create a draft (unpublished) release, `false` to create a published one. Default: `false` + draft: false + # `true` to identify the release as a prerelease. `false` to identify the release as a full release. Default: `false` + prerelease: false + + - name: Pack + run: npm pack + + - name: Rename Pack + run: mv *.tgz npmPackage.tgz + + - name: Upload Package to Release + continue-on-error: true + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # The URL for uploading assets to the release + upload_url: ${{steps.releaseCreate.outputs.upload_url}} + # The path to the asset you want to upload + asset_path: npmPackage.tgz + asset_name: npmPackage.tgz + # The content-type of the asset you want to upload. See the supported Media Types here: https://www.iana.org/assignments/media-types/media-types.xhtml for more information + asset_content_type: application/x-compressed-tar + - name: NPM Publish + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index fb68760..ab83a2a 100644 --- a/package.json +++ b/package.json @@ -17,11 +17,12 @@ "automation" ], "scripts": { - "prepare": "npm run build", "test": "mocha --timeout 60000 -r ts-node/register src/Tests/Tests.*.ts", "lint": "eslint '*/*.ts' --quiet --fix", "build:tsc": "tsc", "build:docs": "typedoc", + "build:all": "npm run build:tsc && npm run build:docs", + "build": "", "example": "npx ts-node Example/example.ts", "browser-decode": "npx ts-node src/BrowserMessageDecoding.ts" }, From 3e43733a32842464d0e184b70e352abdf8254e3d Mon Sep 17 00:00:00 2001 From: AZMCode Date: Wed, 19 Aug 2020 07:28:13 -0400 Subject: [PATCH 3/4] Added capability of auto-testing on CI --- .github/workflows/main.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34fcb98..9707ff8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,22 @@ name: CI on: ["push"] jobs: + Test: + runs-on: ubuntu-latest + steps: + - name: Checkout Commit + uses: actions/checkout@v2 + + - name: Setup Node.js environment + uses: actions/setup-node@v2.1.1 + + - name: Install Dependencies + run: npm install + + - name: Run Tests + run: npm run test Build: + needs: Test runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: From f8524ff6901a6256f2d0ce90de5819259606dced Mon Sep 17 00:00:00 2001 From: AZMCode Date: Wed, 19 Aug 2020 07:35:36 -0400 Subject: [PATCH 4/4] Commented out Test code for future use --- .github/workflows/main.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9707ff8..bf58ff6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,22 +2,21 @@ name: CI on: ["push"] jobs: - Test: - runs-on: ubuntu-latest - steps: - - name: Checkout Commit - uses: actions/checkout@v2 - - - name: Setup Node.js environment - uses: actions/setup-node@v2.1.1 - - - name: Install Dependencies - run: npm install - - - name: Run Tests - run: npm run test +# Test: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout Commit +# uses: actions/checkout@v2 +# +# - name: Setup Node.js environment +# uses: actions/setup-node@v2.1.1 +# +# - name: Install Dependencies +# run: npm install +# +# - name: Run Tests +# run: npm run test Build: - needs: Test runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: