-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github actions for testing and releasing
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: "Setup test environment" | ||
description: "" | ||
inputs: {} | ||
outputs: {} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: cachix/install-nix-action@v20 | ||
- run: | | ||
source <(nix print-dev-env --show-trace) | ||
output_file="nix-env.txt" | ||
# Clear the output file | ||
> $output_file | ||
# Loop over each variable in the environment | ||
while IFS='=' read -r -d '' name value; do | ||
# Skip if the variable is a function or read-only or non-alphanumeric | ||
[[ "$(declare -p $name)" =~ "declare -[a-z]*r[a-z]* " ]] && continue | ||
[[ ! $name =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]] && continue | ||
# Check if the variable value contains a newline | ||
if [[ "$value" != *$'\n'* ]]; then | ||
# It doesn't, so write the variable and its value (stripping quotes) to the file | ||
echo "${name}=${value//\"/}" >> $output_file | ||
fi | ||
done < <(env -0) | ||
# useful for debugging what env is exported | ||
# cat nix-env.txt | ||
shell: bash | ||
- run: cat nix-env.txt >> "$GITHUB_ENV" | ||
shell: bash | ||
- name: Add Gadget npm registry | ||
shell: bash | ||
run: npm config set @gadget-client:registry https://registry.gadget.dev/npm | ||
- name: Install dependencies with pnpm | ||
shell: bash | ||
run: pnpm install |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'package.json' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
release: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./.github/actions/setup-test-env | ||
- id: npm-publish | ||
name: Publish wds to npm | ||
uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
access: public | ||
- name: Publish Release to github | ||
uses: softprops/action-gh-release@v1 | ||
if: ${{ steps.npm-publish.outputs.type != 'none' }} | ||
with: | ||
tag_name: ${{ steps.npm-publish.outputs.version }} | ||
generate_release_notes: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./.github/actions/setup-test-env | ||
- run: pnpm build | ||
- run: pnpm test | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./.github/actions/setup-test-env | ||
- run: pnpm lint |