Skip to content

v0.40.0

v0.40.0 #5025

Workflow file for this run

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# Builds the 'taq' binary on Linux and MacOS. Then create an archive of the work we've done and store it as an artifact to use in later jobs.
build-binaries:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: [16]
runs-on: ${{ matrix.os }}
env:
DENO_DIR: ./.deno
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- uses: denoland/setup-deno@v1
- name: Restore Deno Cache
uses: actions/cache/restore@v3
with:
path: ${{ env.DENO_DIR }}
key: ${{ runner.os }}-deno-${{ hashFiles('deno.lock') }}
- name: Build Binaries
run: |
npm ci
npm run build-types
npm run build:binary
- name: Save Deno Cache
uses: actions/cache/save@v3
with:
path: ${{ env.DENO_DIR }}
key: ${{ runner.os }}-deno-${{ hashFiles('deno.lock') }}
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: taq-${{ matrix.os }}
path: taq
- name: Create archive of work
if: ${{ matrix.os == 'ubuntu-latest' }}
# We need to ignore the exit code of tar because it will exit with 1 if
# a file is being written to while tar is trying to read it. This is
# expected behavior and we don't want to fail the build because of it.
run: |
set +e
tar -czpf work.tar.gz .
exitcode=$?
if [ "$exitcode" != "1" ] && [ "$exitcode" != "0" ]; then
exit $exitcode
fi
set -e
- name: Store work
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: work-${{ matrix.os }}
path: work.tar.gz
retention-days: 1
# Builds all NPM packages. Then update the archive of the work we've done and store it as an artifact to use in later jobs.
build-packages:
needs: build-binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- uses: denoland/setup-deno@v1
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- name: Build packages
run: npm run build:packages
- name: Get VSIX
id: vsix
run: echo "artifact=$(ls taqueria-vscode-extension/*.vsix)" >> "$GITHUB_OUTPUT"
- name: Upload VSCode Extension
uses: actions/upload-artifact@v2
with:
name: taqueria.vsix
path: ${{ steps.vsix.outputs.artifact }}
- name: Create archive of work
# We need to ignore the exit code of tar because it will exit with 1 if
# a file is being written to while tar is trying to read it. This is
# expected behavior and we don't want to fail the build because of it.
run: |
set +e
tar -czpf work.tar.gz .
exitcode=$?
if [ "$exitcode" != "1" ] && [ "$exitcode" != "0" ]; then
exit $exitcode
fi
set -e
- name: Store work
uses: actions/upload-artifact@v2
with:
name: work-ubuntu-latest
path: work.tar.gz
retention-days: 1
# Check whether this commit is related to a PR or if the commit message references an issue
check_is_pr_or_issue:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check_pr_or_issue.outputs.should_run }}
issue_number: ${{ steps.check_pr_or_issue.outputs.issue_number }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Check for PR or Issue
id: check_pr_or_issue
run: |
ISSUE_ID="$(git log --format=%B -n 1 ${{ github.sha }} | grep -Eo '#[0-9]+' | awk 'NR==1{ print $1 }' | tr -d '#')"
SHOULD_RUN="no"
if [[ ! -z "${{ github.event.pull_request.number }}" || ! -z "$ISSUE_ID" ]]; then
SHOULD_RUN="yes"
fi
echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
echo "issue_number=$ISSUE_ID" >> "$GITHUB_OUTPUT"
# Check whether this is a release
check_is_release:
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.check_release.outputs.is_release }}
version: ${{ steps.check_release.outputs.version }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Check for Release
id: check_release
run: |
VERSION=$(node -p "require('./package.json').version")
echo "Version: $VERSION"
IS_RELEASE="no"
if [[ $(echo $VERSION | awk -F. '{print $3}') == "0" ]]; then
IS_RELEASE="yes"
echo "This is a final release"
fi
echo "is_release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Gather package info for publishing
gather-package-info:
runs-on: ubuntu-latest
outputs:
taggedPackages: ${{ steps.gather-packages.outputs.taggedPackages }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Gather package info
id: gather-packages
run: |
PACKAGES=$(npx lerna list --json)
TAGGED_PACKAGES=()
for pkg in $(echo "${PACKAGES}" | jq -r '.[] | @base64'); do
pkg_name=$(echo "$pkg" | base64 --decode | jq -r '.name')
pkg_location=$(echo "$pkg" | base64 --decode | jq -r '.location')
pkg_tag=$(jq -r '.tag // "auto"' < "$pkg_location/package.json")
TAGGED_PACKAGES+=("{\"name\":\"$pkg_name\",\"tag\":\"$pkg_tag\",\"location\":\"$pkg_location\"}")
TAGGED_PACKAGES_JSON="[$(IFS=,; echo "${TAGGED_PACKAGES[*]}")]"
done
echo $TAGGED_PACKAGES_JSON
echo "taggedPackages=$TAGGED_PACKAGES_JSON" >> "$GITHUB_OUTPUT"
# Publish NPM packages to Github Packages
publish-packages:
needs: [build-packages, check_is_release, gather-package-info]
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{fromJson(needs.gather-package-info.outputs.taggedPackages)}}
steps:
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Debug matrix variables
run: echo "PACKAGE_NAME=${{ matrix.package.name }}" && echo "PACKAGE_TAG=${{ matrix.package.tag }}" && echo "PACKAGE_LOCATION=${{ matrix.package.location }}"
- name: List env variables
run: env
# Publish packages
- name: Publish to npm
run: |
export HUSKY=0
rm work.tar.gz
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
git config --global user.email "[email protected]"
git config --global user.name "Michael Weichert"
git commit -am "chore: publish packages" --allow-empty
# Determine the appropriate NPM tag for publishing
# If the "tag" property from package.json is set to "auto",
# we rely on the "is_release" flag.
# Otherwise, we use the specified tag in package.json which should be set to "beta", "alpha", etc.
TAG=${{ matrix.package.tag }}
if [ "$TAG" == "auto" ]; then
TAG="dev"
if [[ "${{ needs.check_is_release.outputs.is_release }}" == "yes" ]]; then
TAG="latest"
fi
fi
# Navigate to package directory
cd ${{ matrix.package.location }}
# Publish using npm with the determined tag
npm publish --tag $TAG
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Publish website
publish-website:
needs: [build-binaries, check_is_release]
runs-on: ubuntu-latest
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
TAQ_VERSION: ${{ needs.check_is_release.outputs.version }}
steps:
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- name: Build Website
run: |
npm run build-website
- name: Publish Website (Preview)
id: publish-website-preview
if: needs.check_is_release.outputs.is_release == 'no'
run: cd website && npm run deploy-preview
- name: Publish Website (Production)
id: publish-website
if: needs.check_is_release.outputs.is_release == 'yes'
run: cd website && npm run deploy
# Publish binaries to Github Releases
publish-release:
needs: [build-binaries, build-packages, check_is_release]
if: needs.check_is_release.outputs.is_release == 'yes'
runs-on: ubuntu-latest
steps:
- name: Download taq binary for Linux
uses: actions/download-artifact@v2
with:
name: taq-ubuntu-latest
path: taq-linux
- name: Download taq binary for MacOS
uses: actions/download-artifact@v2
with:
name: taq-macos-latest
path: taq-macos
- name: Download vscode extension
uses: actions/download-artifact@v2
with:
name: taqueria.vsix
path: vscode-extension
- name: Get VSIX
id: vsix
run: echo "artifact=$(ls vscode-extension/)" >> "$GITHUB_OUTPUT"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.check_is_release.outputs.version }}
release_name: v${{ needs.check_is_release.outputs.version }}
draft: true
prerelease: false
- name: Upload Linux binary
id: upload-linux-binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: taq-linux/taq
asset_name: taq-linux
asset_content_type: application/octet-stream
- name: Upload MacOS binary
id: upload-macos-binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: taq-macos/taq
asset_name: taq-macos
asset_content_type: application/octet-stream
- name: Upload VSCode Extension
id: upload-vsix
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: vscode-extension/${{ steps.vsix.outputs.artifact }}
asset_name: taqueria.vsix
asset_content_type: application/octet-stream
publish-vscode:
needs: [build-packages, check_is_release]
if: needs.check_is_release.outputs.is_release == 'yes'
runs-on: ubuntu-latest
steps:
- name: Download vscode extension
uses: actions/download-artifact@v2
with:
name: taqueria.vsix
path: vscode-extension
- name: Get VSIX
id: vsix
run: echo "artifact=$(ls vscode-extension/)" >> "$GITHUB_OUTPUT"
- name: Publish to Marketplace
uses: HaaLeo/publish-vscode-extension@v1
with:
pat: ${{ secrets.VSCODE_MARKETPLACE_PAT }}
extensionFile: vscode-extension/${{ steps.vsix.outputs.artifact }}
preRelease: false
registryUrl: https://marketplace.visualstudio.com
# Add comment with published artifacts and packages
update-comment:
needs: [publish-packages, check_is_pr_or_issue]
if: needs.check_is_pr_or_issue.outputs.should_run == 'yes'
runs-on: ubuntu-latest
steps:
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- name: Get version
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: List Lerna Packages
id: list_packages
run: |
echo "PACKAGES<<EOF" >> $GITHUB_OUTPUT
npx lerna ls --json | jq -r '.[] | "| \(.name) | \(.version) |"' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Update or Create comment
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
issue-number: ${{ github.event.pull_request.number || needs.check_is_pr_or_issue.outputs.issue_number }}
body: |
## Published Binaries & Packages
| Published | Version |
| :--- | :--- |
| Taq Binary (MacOS) | [${{ steps.get_version.outputs.VERSION }}](https://github.com/${{ github.repository }}/actions/artifacts) |
| Taq Binary (Windows) | [${{ steps.get_version.outputs.VERSION }}](https://github.com/${{ github.repository }}/actions/artifacts) |
| VSIX for VSCode Extension | [${{ steps.get_version.outputs.VERSION }}](https://github.com/${{ github.repository }}/actions/artifacts) |
${{ steps.list_packages.outputs.PACKAGES }}
<!-- Add more rows for additional packages -->
> Note: You can install the latest development version of a package with `taq install @taqueria/[packageName]@dev`.
edit-mode: replace
list-e2e-tests:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: List .spec.ts files
id: list
run: echo "files=$(ls tests/e2e/*.spec.ts | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
- name: Set matrix for next job
id: set-matrix
run: echo 'matrix={"spec":${{ steps.list.outputs.files }}}' >> "$GITHUB_OUTPUT"
- name: Debug
run: echo ${{fromJson(steps.set-matrix.outputs.matrix)}}
run-e2e-tests:
needs:
- list-e2e-tests
- build-packages
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.list-e2e-tests.outputs.matrix)}}
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- name: Run tests
env:
HUSKY_SKIP_INSTALL: 1
HUSKY: 0
run: |
CWD=$(pwd)
export PATH=$PATH:$CWD
npm run test:e2e -w tests ${{ matrix.spec }}
list-integration-tests:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: List .spec.ts files
id: list
run: echo "files=$(ls tests/integration/*.spec.ts | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
- name: Set matrix for next job
id: set-matrix
run: echo 'matrix={"spec":${{ steps.list.outputs.files }}}' >> "$GITHUB_OUTPUT"
- name: Debug
run: echo ${{fromJson(steps.set-matrix.outputs.matrix)}}
run-integration-tests:
needs:
- list-integration-tests
- build-packages
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.list-integration-tests.outputs.matrix)}}
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- name: Run tests
env:
HUSKY_SKIP_INSTALL: 1
HUSKY: 0
run: |
CWD=$(pwd)
export PATH=$PATH:$CWD
npm run test:integration -w tests ${{ matrix.spec }}
# Run all unit tests
run-unit-tests:
needs:
- build-binaries
- build-packages
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: denoland/setup-deno@v1
- name: Download work archive
uses: actions/download-artifact@v2
with:
name: work-ubuntu-latest
path: .
- name: Extract work archive
run: tar -xzpf work.tar.gz
- name: Run tests
env:
HUSKY_SKIP_INSTALL: 1
HUSKY: 0
npm_config_loglevel: silly
run: |
CWD=$(pwd)
export PATH=$PATH:$CWD
export DENO_DIR=$CWD/.deno
npm run test:unit -w tests