diff --git a/.github/workflows/main.yml b/.github/workflows/publish-release.yml similarity index 68% rename from .github/workflows/main.yml rename to .github/workflows/publish-release.yml index 8035aac..e8f78fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/publish-release.yml @@ -1,5 +1,4 @@ -name: CI - +name: Publish Release on: "workflow_dispatch" @@ -41,59 +40,11 @@ jobs: uses: actions/setup-node@v2.1.1 - name: Install Dependencies - run: npm install + run: yarn - 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 + run: yarn run build:all - - Publish-Docs: - if: github.ref == 'refs/heads/master' - 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 - build_dir: docs - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - Publish-Package: - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' - 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: Debug Release Creation run: echo "${{ toJson(needs) }}" @@ -113,14 +64,11 @@ jobs: 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 + - name: Git Release uses: actions/upload-release-asset@v1.0.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -132,7 +80,8 @@ jobs: 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 }} + token: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 0000000..9d0d11d --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,41 @@ +name: Update Docs + +on: + push: + branches: + - master +jobs: + Build: + runs-on: ubuntu-latest + outputs: + package-name: ${{ steps.packageInfo.outputs.package-name }} + package-version: ${{ steps.packageInfo.outputs.package-version }} + commit-msg: ${{ steps.packageInfo.outputs.commit-msg }} + # 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: yarn + + - name: Build + run: yarn run build:all + + - name: Publish to Pages + uses: crazy-max/ghaction-github-pages@v2 + with: + target_branch: gh-pages + build_dir: docs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/package.json b/package.json index 86f62ee..19dff42 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,11 @@ ], "scripts": { "test": "mocha --timeout 240000 -r ts-node/register src/Tests/Tests.*.ts", - "prepare": "tsc", + "prepare": "npm run build:tsc", "lint": "eslint '*/*.ts' --quiet --fix", + "build:all": "npm run build:tsc && npm run build:docs", "build:docs": "typedoc", + "build:tsc": "tsc", "example": "npx ts-node Example/example.ts", "browser-decode": "npx ts-node src/BrowserMessageDecoding.ts" },