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: Test, Build & Publish | |
on: | |
push: | |
branches: '**' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 7 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm install, build, and test | |
run: | | |
pnpm install --no-audit --legacy-peer-deps | |
pnpm run ts:lint | |
# fix for https://github.com/cibernox/ember-power-select/pull/1577 | |
rm -rf node_modules/ember-power-select/components | |
pnpm run glint | |
pnpm run test | |
env: | |
CI: true | |
ember-try: | |
name: ember-try (${{ matrix.scenario }}) | |
needs: test | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.experimental }} | |
env: | |
CI: 'true' | |
strategy: | |
fail-fast: false | |
matrix: | |
experimental: [false] | |
scenario: | |
- release | |
include: | |
- scenario: beta | |
experimental: true | |
- scenario: canary | |
experimental: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 7 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies (pnpm) | |
run: | | |
pnpm install | |
- name: Setup ember-try scenario | |
run: ./node_modules/.bin/ember try:one ember-${{ matrix.scenario }} --skip-cleanup --- cat package.json | |
- name: Build | |
run: ./node_modules/.bin/ember build --environment test | |
- name: Run test | |
run: ./node_modules/.bin/ember test | |
deploy: | |
needs: [test, ember-try] | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 7 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm install, build, and deploy docs | |
run: | | |
mkdir ~/.ssh | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
pnpm install | |
version=$(cat package.json | jq -r '.version') | |
git fetch --unshallow | |
git fetch --all --tags | |
TAG=v$version | |
if git rev-parse "$TAG" >/dev/null 2>&1; then | |
echo "tag exists"; | |
else | |
ADDON_DOCS_UPDATE_LATEST=false ADDON_DOCS_VERSION_PATH=$TAG ./node_modules/.bin/ember deploy production | |
ADDON_DOCS_UPDATE_LATEST=true ADDON_DOCS_VERSION_PATH=$TAG ./node_modules/.bin/ember deploy production | |
fi | |
ADDON_DOCS_UPDATE_LATEST=false ADDON_DOCS_VERSION_PATH=main ./node_modules/.bin/ember deploy production | |
env: | |
CI: true | |
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | |
- name: deploy pnpm | |
if: github.ref == 'refs/heads/main' | |
run: | | |
version=$(cat package.json | jq -r '.version') | |
TAG=v$version | |
if git rev-parse "$TAG" >/dev/null 2>&1; then | |
echo "tag exists"; | |
else | |
pnpm run precompile | |
cd precompiled | |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | |
pnpm run ts:build-types | |
pnpm publish || echo "already published" | |
fi | |
env: | |
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}" | |
- name: create tag | |
if: github.ref == 'refs/heads/main' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
GITHUB_ACTOR: ${{ github.actor }} | |
GITHUB_COMMIT: ${{ github.sha }} | |
run: | | |
version=$(cat package.json | jq -r '.version') | |
TAG=v$version | |
if git rev-parse "$TAG" >/dev/null 2>&1; then | |
echo "tag exists"; | |
else | |
pnpm i -g lerna-changelog | |
export GITHUB_AUTH=$GITHUB_TOKEN | |
export changelog=$(lerna-changelog --next-version=$version) | |
echo -e "# Changelog\n\n$changelog\n$(tail --lines=+2 CHANGELOG.md)" > CHANGELOG.md | |
git add CHANGELOG.md | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "update changelog" | |
git tag $TAG | |
git push | |
git push --tags | |
fi | |
- name: Create a Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
version=$(cat package.json | jq -r '.version') | |
TAG=v$version | |
url="https://api.github.com/repos/ibm/carbon-components-ember/releases" | |
exists=$(curl -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" $url | jq ".[] | select(.tag_name == \"$TAG\") | .id") | |
if [[ -z $exists ]]; then | |
curl -X POST -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" $url -d "{ \"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"body\": \"$changelog\", \"draft\": false, \"prerelease\": false}" | |
else | |
echo "release already exists"; | |
fi; |