Skip to content

Commit

Permalink
test: new ci (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed May 24, 2024
1 parent 3f95fb3 commit 5b418fd
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
127 changes: 127 additions & 0 deletions .github/workflows/ci_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: ci package
on:
workflow_dispatch:
inputs:
package:
description: Package
required: true
type: choice
options:
- bundle
- crypto
- diff
- logger
- orm
- qrcode
- reactive
- testing
- typing
- xml
publish:
description: Publish
type: boolean
default: false
#workflow_call:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno lint
working-directory: ${{ inputs.package }}
- run: deno fmt --check
working-directory: ${{ inputs.package }}

test:
name: Build, test and bench
runs-on: ubuntu-latest
outputs:
has_build: ${{ steps.package.outputs.has_build }}
has_bench: ${{ steps.package.outputs.has_bench }}
tag: ${{ steps.tag.outputs.tag }}
permissions:
contents: read
steps:
# Setup
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
- name: check package requirements
id: package
run: |
echo "has_build=$(deno eval 'Deno.stdout.writeSync(new TextEncoder().encode(JSON.parse(Deno.readTextFileSync(`deno.jsonc`))?.tasks?.build ?? ``))')" >> "$GITHUB_OUTPUT"
echo "has_bench=$(deno eval 'Deno.stdout.writeSync(new TextEncoder().encode(JSON.parse(Deno.readTextFileSync(`deno.jsonc`))?.tasks?.bench ?? ``))')" >> "$GITHUB_OUTPUT"
working-directory: ${{ inputs.package }}
# Build
- run: deno task build
if: ${{ steps.package.outputs.has_build }}
working-directory: ${{ inputs.package }}
# Tests
- run: deno task dev
working-directory: ${{ inputs.package }}
- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v1
- run: deno task ci
working-directory: ${{ inputs.package }}
# Bench
- run: deno task bench
if: ${{ steps.package.outputs.has_bench }}
working-directory: ${{ inputs.package }}
# Tag
- id: tag
uses: ldelarue/git-next-tag@v0.4
with:
tag-prefix: ${{ inputs.package }}-
scope: ${{ inputs.package }}

publish:
name: Publish
if: github.ref == 'refs/heads/main' && ${{ inputs.publish }}
runs-on: ubuntu-latest
needs:
- lint
- test
permissions:
id-token: write
contents: write
packages: write
steps:
# Setup
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
- name: git config
run: git config user.name 'github-actions[bot]' && git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
# Build
- name: deno task build
if: ${{ needs.test.outputs.has_build }}
run: |
deno task build
git add .
git commit -m 'chore(${{ inputs.package }}): rebuild package'
git pull --ff-only
git push
working-directory: ${{ inputs.package }}
# Tag
- name: deno task tag
run: |
deno task tag --version '${{ needs.test.outputs.tag }}' ${{ inputs.package }}
deno fmt deno.jsonc
git add deno.jsonc
git commit -m "chore(${{ inputs.package }}): bump version ${{ needs.test.outputs.tag }}"
git pull --ff-only
git push
working-directory: ${{ inputs.package }}
- name: git tag
run: |
git tag '${{ needs.test.outputs.tag }}'
git show-ref --tags '${{ needs.test.outputs.tag }}'
git pull --ff-only
git push origin '${{ needs.test.outputs.tag }}'
working-directory: ${{ inputs.package }}
# Publish
- run: deno task publish
working-directory: ${{ inputs.package }}

0 comments on commit 5b418fd

Please sign in to comment.