diff --git a/.github/workflows/npm_publish_webview.yml b/.github/workflows/npm_publish_webview.yml new file mode 100644 index 00000000..3e8053b9 --- /dev/null +++ b/.github/workflows/npm_publish_webview.yml @@ -0,0 +1,79 @@ +name: Build and Package latest webview + +on: + push: + branches: + - derrick/cod-1272-ci-action-to-publish-js-bundle-artifact + - 'releases/**' + - development + +env: + NODE_ENV: ${{ secrets.NODE_ENV }} + FORCE_CLIENT_CHECK: ${{ secrets.FORCE_CLIENT_CHECK }} + API_URL: ${{ secrets.API_URL }} + PUSHER_AUTH_ENDPOINT: ${{ secrets.PUSHER_AUTH_ENDPOINT }} + PUSHER_APP_KEY: ${{ secrets.PUSHER_APP_KEY }} + PUSHER_CLUSTER: ${{ secrets.PUSHER_CLUSTER }} + SENTRY_DNS: ${{ secrets.SENTRY_DNS }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + LOG_MAX_FILE_SIZE: 5242880 + LOG_MAX_FILES: 10 + LOG_LEVEL: "debug" + POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }} + SEGMENT_KEY: ${{ secrets.SEGMENT_KEY }} + +jobs: + test: + uses: ./.github/workflows/npm_ci_tests.yml + secrets: + CODEX_PUBLIC_KEY: ${{ secrets.CODEX_PUBLIC_KEY }} + CODEX_PRIVATE_KEY: ${{ secrets.CODEX_PRIVATE_KEY }} + READ_PACKAGES_TOKEN: ${{ secrets.READ_PACKAGES_TOKEN }} + + build: + env: + NODE_AUTH_TOKEN: ${{ secrets.READ_PACKAGES_TOKEN }} + needs: test + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + # Setup .npmrc file to publish to GitHub Packages + - uses: actions/setup-node@v2 + with: + node-version: '16.x' + registry-url: 'https://npm.pkg.github.com' + scope: "@usecodex" + + - name: Install global packages + run: npm i -g rollup + + - name: Install dependencies + run: npm ci --include=dev + working-directory: ./codex-webview + env: + GITHUB_TOKEN: ${{ secrets.READ_PACKAGES_TOKEN }} + + - name: Configure git author + run: | + git --version + git config user.name "GitHub Actions Bot" + git config user.email "<>" + + - name: Add SHORT_SHA env property with commit short sha + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + + - name: Bump patch version to alpha + working-directory: ./codex-webview + run: npm version prerelease --preid="alpha-${SHORT_SHA}" + + - name: Bump patch version to beta + if: github.ref == 'refs/heads/development' + working-directory: ./codex-webview + run: npm version prerelease --preid="beta-${SHORT_SHA}" + + - name: Publish + working-directory: ./codex-webview + run: npm publish diff --git a/codex-webview/.npmrc b/codex-webview/.npmrc index a0a68a8a..b8d26615 100644 --- a/codex-webview/.npmrc +++ b/codex-webview/.npmrc @@ -1,2 +1,2 @@ @usecodex:registry=https://npm.pkg.github.com/ -//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} +//npm.pkg.github.com:_authToken=${GITHUB_TOKEN} diff --git a/codex-webview/package.json b/codex-webview/package.json index ee6ba307..baecf351 100644 --- a/codex-webview/package.json +++ b/codex-webview/package.json @@ -8,14 +8,19 @@ "watch": "rollup -c -w", "build:css": "tailwind build -i media/style.css -o out/style.css", "build": "npm run build:css && rollup -c", - "test": "echo \"Error: TODO: Set up unit tests\" && exit 1" + "test": "echo \"Error: TODO: Set up unit tests\" && exit 1", + "prepublish": "npm run build" }, "files": [ - "out" + "out" ], "publishConfig": { "registry": "https://npm.pkg.github.com" }, + "repository": { + "type": "git", + "url": "git+https://github.com/usecodex/codex-vscode.git" + }, "keywords": [], "devDependencies": { "@fullhuman/postcss-purgecss": "^4.0.3",