Build and Publish #5991
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish | |
on: | |
pull_request: {} | |
push: | |
branches: | |
- main | |
- stable | |
- ember-2.7.0-3.4.0 | |
- ember-0.0.0-2.7.0 | |
tags: | |
- v* | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
env: | |
CI: 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Code Climate expects these variables to be set | |
- name: Set up commit metadata | |
if: github.event_name == 'push' | |
env: | |
GIT_COMMIT_SHA: ${{ github.sha }} | |
GIT_BRANCH: ${{ github.ref }} | |
run: | | |
echo "GIT_COMMIT_SHA=${GIT_COMMIT_SHA}" >> $GITHUB_ENV | |
echo "GIT_BRANCH=${GIT_BRANCH/refs\/heads\//}" >> $GITHUB_ENV | |
- name: Set up commit metadata | |
if: github.event_name == 'pull_request' | |
env: | |
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
GIT_BRANCH: ${{ github.event.pull_request.head.ref }} | |
run: | | |
echo "GIT_COMMIT_SHA=${GIT_COMMIT_SHA}" >> $GITHUB_ENV | |
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV | |
- name: setup pnpm & node | |
uses: wyvox/action-setup-pnpm@v3 | |
- name: Install dependencies (pnpm) | |
run: pnpm install | |
- name: Lint (hbs) | |
run: pnpm lint:hbs | |
- name: Lint (js) | |
run: pnpm lint:js | |
- name: Run test | |
run: pnpm test | |
env: | |
COVERAGE: 'true' | |
# Ideally, we would split up the test task into separate build and run | |
# steps to get better CI log output (folding and timing information). | |
# However, this is not currently possible with ember-cli-code-coverage. | |
# | |
# See https://github.com/kategengler/ember-cli-code-coverage/issues/210 | |
# | |
# - name: Build | |
# run: pnpm ember build --environment test | |
# env: | |
# COVERAGE: 'true' | |
# - name: Run test | |
# run: COVERAGE pnpm ember test --path dist | |
# env: | |
# # 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 | |
# EMBER_ENV: test | |
# COVERAGE: 'true' | |
- name: Report coverage | |
if: github.event_name != 'schedule' | |
run: pnpm codeclimate-test-reporter < coverage/lcov.info | |
env: | |
CODECLIMATE_REPO_TOKEN: 59edcfd1ffc778791af49ca594b503e7179f6bbe1991b2cc0c0a6987d103253d | |
ember-try: | |
name: ember-try (${{ matrix.scenario }}) | |
needs: test | |
runs-on: ubuntu-latest | |
env: | |
CI: 'true' | |
strategy: | |
fail-fast: false | |
matrix: | |
scenario: | |
- ember-lts-3.16 | |
- ember-lts-3.20 | |
- ember-lts-3.24 | |
- ember-lts-3.28 | |
- ember-release | |
- ember-beta | |
- ember-canary | |
- ember-default-no-prototype-extensions | |
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: Set NO_EXTEND_PROTOTYPES | |
if: matrix.scenario == 'ember-default-no-prototype-extensions' | |
run: echo "NO_EXTEND_PROTOTYPES==true" >> .GITHUB_ENV | |
- name: Setup ember-try scenario | |
run: pnpm ember try:one ${{ matrix.scenario }} --skip-cleanup --- cat package.json | |
- name: Build | |
run: pnpm ember build --environment test | |
- name: Run test | |
# 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/[email protected] | |
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_NIGHTLY_CLIENT_ID }}" >> $GITHUB_ENV | |
echo "REFRESH_TOKEN=${{ secrets.GOOGLE_NIGHTLY_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 | |
fi |