diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e908a99e9d..aef701f620 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,3 +110,251 @@ jobs: # Due to a bug in ember-cli, running `ember test` with `--path` doesn't set `EMBER_ENV=test` # See https://github.com/ember-cli/ember-cli/issues/8922 run: EMBER_ENV=test pnpm ember test --path dist --filter="Ember Debug" + + build: + name: Build extensions + runs-on: ubuntu-latest + env: + CI: 'true' + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: setup pnpm & node + uses: wyvox/action-setup-pnpm@v3 + - name: Install dependencies (pnpm) + run: pnpm install + - name: Download panes + run: node scripts/download-panes.js + env: + EMBER_ENV: production + - name: Update manifest.json (nightly) + if: github.event_name == 'schedule' + run: | + DATE="$(date +"%Y.%-m.%-d")" + SHA="${GITHUB_SHA:0:7}" + VERSION="$(jq -r '.version' package.json)" + CONTENT="$(cat "$FILE")" + + echo "$CONTENT" | jq --arg date "$DATE" --arg sha "$SHA" --arg version "$VERSION" "$FILTER" > $FILE + cat "$FILE" + env: + FILE: skeletons/web-extension/manifest.json + FILTER: >- + .name += " (Nightly)" | + .version = $date | + .version_name = "\($version) (nightly build \($date) / \($sha))" + - name: Update manifest.json (pull request) + if: github.event_name == 'pull_request' + run: | + SHA="${SHA:0:7}" + CONTENT="$(cat "$FILE")" + + echo "$CONTENT" | jq --arg pr "$PR" --arg sha "$SHA" "$FILTER" > $FILE + cat "$FILE" + env: + FILE: skeletons/web-extension/manifest.json + FILTER: >- + .name += " (PR #\($pr))" | + .version = $pr | + .version_name = $sha + PR: ${{ github.event.pull_request.number }} + SHA: ${{ github.event.pull_request.head.sha }} + - name: Update package.json (nightly) + if: github.event_name == 'schedule' + run: | + DATE="$(date +"%Y.%-m.%-d")" + SHA="${GITHUB_SHA:0:7}" + CONTENT="$(cat "$FILE")" + + echo "$CONTENT" | jq --arg date "$DATE" --arg sha "$SHA" "$FILTER" > $FILE + cat "$FILE" + env: + FILE: package.json + FILTER: .version += "-alpha.\($date)+\($sha)" + - name: Update package.json (pull request) + if: github.event_name == 'pull_request' + run: | + SHA="${SHA:0:7}" + CONTENT="$(cat "$FILE")" + + echo "$CONTENT" | jq --arg pr "$PR" --arg sha "$SHA" "$FILTER" > $FILE + cat "$FILE" + env: + FILE: package.json + FILTER: .version += "-alpha.0.\($pr)+\($sha)" + PR: ${{ github.event.pull_request.number }} + SHA: ${{ github.event.pull_request.head.sha }} + - name: Set EMBER_INSPECTOR_TAB (nightly) + if: github.event_name == 'schedule' + run: echo "EMBER_INSPECTOR_TAB=Nightly" >> $GITHUB_ENV + - name: Set EMBER_INSPECTOR_TAB (pull request) + if: github.event_name == 'pull_request' + run: echo "EMBER_INSPECTOR_TAB=PR \#$PR" >> $GITHUB_ENV + env: + PR: ${{ github.event.pull_request.number }} + - name: Build + run: pnpm ember build --environment production + - name: Pack + run: | + VERSION="$(jq -r '.version' package.json)" + + pnpm pack + mkdir -p dist/npm + tar xvzf "ember-inspector-$VERSION.tgz" -C dist/npm --strip-components 1 + - name: Upload artifacts (bookmarklet) + uses: actions/upload-artifact@v4 + with: + name: bookmarklet + path: dist/bookmarklet + - name: Upload artifacts (Chrome) + uses: actions/upload-artifact@v4 + with: + name: chrome + path: dist/chrome + - name: Upload artifacts (Firefox) + uses: actions/upload-artifact@v4 + with: + name: firefox + path: dist/firefox + - name: Upload artifacts (npm) + uses: actions/upload-artifact@v4 + with: + name: npm + path: dist/npm + + publish-bookmarklet: + name: Publish bookmarklet + needs: + - test + - ember-try + - build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Download artifacts (bookmarklet) + uses: actions/download-artifact@v4 + with: + name: bookmarklet + path: bookmarklet + - name: Upload to S3 + uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --acl public-read --cache-control "max-age=86400000,public" + env: + AWS_S3_BUCKET: ember-extension + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SOURCE_DIR: bookmarklet + DEST_DIR: dist_bookmarklet + + publish-chrome: + name: Publish Chrome extension + needs: + - test + - ember-try + - build + runs-on: ubuntu-latest + steps: + - name: Set up node + uses: actions/setup-node@v4 + - name: Install dependencies (chrome-webstore-upload-cli) + run: npm install -g chrome-webstore-upload-cli + - name: Download artifacts (Chrome) + uses: actions/download-artifact@v4 + with: + name: chrome + path: chrome + - name: Set Environment Variables + run: | + if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then + echo "EXTENSION_ID=ibdbkmdgflhglikhjdbogjjflkialpfi" >> $GITHUB_ENV + echo "CLIENT_ID=${{ secrets.GOOGLE_NIGHTLY_CLIENT_ID }}" >> $GITHUB_ENV + echo "REFRESH_TOKEN=${{ secrets.GOOGLE_NIGHTLY_REFRESH_TOKEN }}" >> $GITHUB_ENV + else + echo "EXTENSION_ID=bmdblncegkenkacieihfhpjfppoconhi" >> $GITHUB_ENV + echo "CLIENT_ID=${{ secrets.GOOGLE_STABLE_CLIENT_ID }}" >> $GITHUB_ENV + echo "REFRESH_TOKEN=${{ secrets.GOOGLE_STABLE_REFRESH_TOKEN }}" >> $GITHUB_ENV + fi + - name: Upload to Chrome Web Store + if: >- + github.event_name == 'schedule' || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) + run: chrome-webstore-upload upload --source chrome --auto-publish + + publish-firefox: + name: Publish Firefox extension + needs: + - test + - ember-try + - build + runs-on: ubuntu-latest + steps: + - name: Set up nod + uses: actions/setup-node@v4 + - name: Install dependencies (web-ext) + run: | + npm install -g web-ext + # https://github.com/mozilla/web-ext/issues/804 + npm install -g web-ext-submit + - name: Download artifacts (Firefox) + uses: actions/download-artifact@v4 + with: + name: firefox + path: firefox + - name: Upload to AMO + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + working-directory: firefox + run: web-ext-submit --channel=listed + env: + WEB_EXT_API_KEY: ${{ secrets.FIREFOX_API_KEY }} + WEB_EXT_API_SECRET: ${{ secrets.FIREFOX_API_SECRET }} + + publish-npm: + name: Publish npm package + needs: + - test + - ember-try + - build + runs-on: ubuntu-latest + steps: + - name: Set up node + uses: actions/setup-node@v4 + - name: Download artifacts (npm) + uses: actions/download-artifact@v4 + with: + name: npm + path: npm + - name: Publish to npm + if: >- + github.event_name == 'schedule' || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) + env: + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + working-directory: npm + run: | + echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}"> ~/.npmrc + npm whoami + if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then + npm publish --tag alpha + else + npm publish + fi + + publish-github: + name: Publish GitHub release + needs: + - test + - ember-try + - build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Create release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false