Skip to content

Commit

Permalink
pkgx
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Sep 30, 2023
1 parent 6aed902 commit a1425ae
Show file tree
Hide file tree
Showing 58 changed files with 502 additions and 458 deletions.
25 changes: 6 additions & 19 deletions .github/deno-to-node.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#!/usr/bin/env -S tea -E
#!/usr/bin/env -S pkgx +npm deno run --allow-env --allow-read --allow-write --allow-net --allow-run

/*---
args:
- deno
- run
- --allow-env
- --allow-read
- --allow-write
- --allow-net
- --allow-run
dependencies:
npmjs.com: '*'
---*/

import { build, emptyDir } from "https://deno.land/x/[email protected]/mod.ts";
import { build, emptyDir } from "https://deno.land/x/[email protected]/mod.ts";
import SemVer from "../src/utils/semver.ts";

await emptyDir("./dist");
Expand Down Expand Up @@ -46,24 +33,24 @@ await build({
"./src/utils/flock.deno.ts": "./src/utils/flock.node.ts"
},
package: {
name: "@teaxyz/lib",
name: "libpkgx",
version,
description: "pkging primitives",
license: "Apache-2.0",
repository: {
type: "git",
url: "git://github.com/teaxyz/lib.git",
url: "git://github.com/pkgxdev/lib.git",
},
bugs: {
url: "https://github.com/teaxyz/lib/issues",
url: "https://github.com/pkgxdev/lib/issues",
},
dependencies: {
"is-what": "^4",
"outdent": "^0.8",
},
exports: {
"./src/src/utils/semver": {
//TODO remove when gui is updated to use `@teaxyz/lib/semver`
//TODO remove when gui is updated to use `libpkgx/semver`
import: "./src/src/utils/semver.ts"
},
"./semver": {
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/cd.npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: cd·npm

on:
release:
types:
- published

concurrency:
group: cd/vx/${{ github.event.release.tag_name }}
cancel-in-progress: true

permissions:
contents: write

jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- uses: robinraju/[email protected]
with:
releaseId: ${{ github.event.release.id }}

- run: |
mkdir dist
tar xf *.tar.xz --directory=dist --strip-components=1
# if we don’t do this the npm publish step doesn’t work
- uses: actions/setup-node@v2
with:
registry-url: https://registry.npmjs.org

- run: npm publish --access public
working-directory: dist
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/cd.vx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: cd·vx

on:
release:
types:
- published

concurrency:
group: cd/vx/${{ github.event.release.tag_name }}
cancel-in-progress: true

permissions:
contents: write

jobs:
retag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: fischerscode/tagger@v0
with:
prefix: v
89 changes: 28 additions & 61 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,53 @@
name: CD
name: cd

on:
release:
types:
- created
- edited
workflow_dispatch:
inputs:
version:
required: true

permissions:
contents: read

concurrency:
group: ${{ github.event.release.tag_name }}
group: v${{ inputs.version }}
cancel-in-progress: true

jobs:
check:
if: ${{ github.event.release.prerelease }}
uses: ./.github/workflows/ci.yml

dnt:
needs: [check]
qa:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- [self-hosted, macOS, X64]
- [self-hosted, linux, X64]
- [self-hosted, macOS, ARM64]
- [self-hosted, linux, ARM64]
- ubuntu-latest # ∵ resilience: PRs verify dnt with this env
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- run: deno task dnt ${{ github.event.release.name }}

- uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
path: dist
- uses: actions/checkout@v4
- uses: pkgxdev/dev@v0
- run: deno task dnt

publish-npm:
needs: [dnt]
attach:
runs-on: ubuntu-latest
needs: qa
steps:
- uses: actions/download-artifact@v3

# if we don’t do this the npm publish step doesn’t work
- uses: actions/setup-node@v2
with:
registry-url: https://registry.npmjs.org
- uses: actions/checkout@v4
- uses: pkgxdev/dev@v0

- run: npm publish --access public
working-directory: artifact
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: deno task dnt ${{ inputs.version }}

publish:
needs: [publish-npm]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Convert pre-release to release
run: |
curl -fX PATCH \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"draft": false, "prerelease": false, "make_latest": true, "tag_name": "${{ github.event.release.name }}"}' \
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}"
# delete pre-release tag
- run: |
git push origin :${{ github.event.release.tag_name }}
git tag -d ${{ github.event.release.tag_name }}
# we need the new tag for the next step
- run: git fetch origin --tags

- uses: fischerscode/tagger@v0
with:
prefix: v
tag: ${{ github.event.release.name }}
mv dist libpkgx-${{inputs.version}}
tar cJf libpkgx-${{ inputs.version }}.tar.xz libpkgx-${{inputs.version}}
- name: attach to release
run:
gh release upload
--clobber
libpkgx-${{ inputs.version }}.tar.xz
env:
# using this token rather than github.token due to `release not found` bug
# https://github.com/cli/cli/issues/5252
GH_TOKEN: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
GH_REPO: pkgxdev/libpkgx
30 changes: 13 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,39 @@ on:
- '**/*.ts'
- .github/workflows/ci.yml
workflow_dispatch:
workflow_call:

concurrency:
group: ${{ github.ref || github.event.release.name }}
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno cache mod.ts

- run: deno task test
--coverage=cov_profile
--no-check # ⬆signal∶noise & ∵ we have `jobs.typecheck`

- run: deno coverage cov_profile --lcov --exclude=tests/ --output=cov_profile.lcov
if: ${{ github.event_name != 'release' }}
- run: deno coverage cov_profile --lcov --output=cov_profile.lcov

- uses: coverallsapp/github-action@v1
if: ${{ github.event_name != 'release' }}
with:
path-to-lcov: cov_profile.lcov
parallel: true
flag-name: ${{ matrix.platform.id }}

upload-coverage:
if: ${{ github.event_name != 'release' }}
needs: tests
runs-on: ubuntu-latest
steps:
Expand All @@ -54,19 +51,18 @@ jobs:
# we’re checking no import-map type imports snuck in
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: src
- uses: denoland/setup-deno@v1
- run: deno run --no-config --unstable src/mod.ts

dnt:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'release' }}
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- run: deno task dnt
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno run -A --unstable .github/deno-to-node.ts

- run: |
npm i
Expand All @@ -77,13 +73,13 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- run: deno task typecheck
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 tea.inc.
Copyright 2023 pkgx inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit a1425ae

Please sign in to comment.