Skip to content

Commit

Permalink
switch from pkg to oclif pack
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Razon committed Jan 10, 2024
1 parent f2b1f88 commit b966819
Show file tree
Hide file tree
Showing 21 changed files with 145 additions and 597 deletions.
114 changes: 68 additions & 46 deletions .github/workflows/gh-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,86 @@ on:

jobs:
build-binaries:
runs-on: macos-latest
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
id-token: write
strategy:
matrix:
arch: [x64,arm64]
platform: [linux,macos,win]
exclude:
- platform: win
arch: arm64
env:
TARBALL_TARGETS: linux-x64,linux-arm64,darwin-x64,darwin-arm64,win32-x64

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: depot/setup-action@v1
with:
oidc: true

- name: Build using Docker (with depot)
run: mkdir preevy-bin && depot build --project ${{ vars.DEPOT_PROJECT_ID }} --build-arg CLI_TARGET=${{ matrix.platform }}-${{ matrix.arch }} -f Dockerfile.cli --target=cli --output=type=tar,dest=./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar --progress=plain --platform=linux/${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} .
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
aws-region: us-west-2

- uses: apple-actions/import-codesign-certs@v2
if: ${{ matrix.platform == 'macos' }}
- uses: actions/setup-node@v4
with:
p12-file-base64: ${{ secrets.APPLE_CERT_DATA }}
p12-password: ${{ secrets.APPLE_CERT_PASS }}
node-version: '18.x'
cache: yarn

- run: yarn

- run: yarn build

- name: Sign mac binaries
if: ${{ matrix.platform == 'macos' }}
env:
CERT_CN: ${{ vars.APPLE_CERT_CN }}
- name: Find packaged node version
id: find_packaged_node_version
working-directory: packages/cli
run: |
tar -xf ./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar
codesign --remove-signature ./preevy
security find-identity -v
codesign --verbose=4 --sign "$CERT_CN" ./preevy
tar -cf ./preevy-bin/preevy-${{ matrix.platform }}-${{ matrix.arch }}.tar ./preevy
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: preevy-bin-${{ matrix.platform }}-${{ matrix.arch }}
path: ./preevy-bin/**
echo "NODE_VERSION=$(jq -r .oclif.update.node.version package.json)" >> "${GITHUB_OUTPUT}"
release:
runs-on: ubuntu-latest
needs: build-binaries
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: depot/setup-action@v1
- name: Download artifacts
uses: actions/download-artifact@v4
- uses: actions/cache@v3
id: cache-oclif-pack
name: Setup cache for oclif pack
with:
pattern: preevy-bin-*
path: ./preevy-bin
merge-multiple: true
path: packages/cli/tmp/cache
key: preevy-oclif-pack-node-v${{ steps.find_packaged_node_version.outputs.NODE_VERSION }}

- name: Pack tarballs
working-directory: packages/cli
run: yarn oclif pack tarballs --parallel --no-xz --targets $TARBALL_TARGETS

- name: Upload tarballs
working-directory: packages/cli
run: yarn oclif upload tarballs --no-xz --targets $TARBALL_TARGETS

- name: Create redirects to version without git sha
# if: startsWith(github.ref, 'refs/tags/')
working-directory: packages/cli
run: |
bucket="$(jq -r .oclif.update.s3.bucket package.json)"
version=$(jq -r .version package.json)
git_sha="$(git rev-parse --short HEAD)"
temp_file="${RUNNER_TEMP}/redir_${RANDOM}"
function create_s3_redirect() {
local from=$1
local to=$2
echo "Redirecting to ${to}" > "${temp_file}"
echo "Creating redirect from ${from} to ${to}"
aws s3 cp "${temp_file}" "s3://${bucket}${from}" --quiet --website-redirect "${to}" --acl public-read
}
for target in ${TARBALL_TARGETS//,/ }; do
for suffix in .tar.gz -buildmanifest; do
create_s3_redirect /versions/${version}/preevy-v${version}-${target}${suffix} /versions/${version}/preevy-v${version}-${git_sha}-${target}${suffix}
done
done
- name: Rename tarballs
# if: startsWith(github.ref, 'refs/tags/')
working-directory: packages/cli/dist
run: |
git_sha="$(git rev-parse --short HEAD)"
for f in $(find . -maxdepth 1 -type f -name 'preevy-v*'); do
new_name="$(echo ${f} | sed 's/-'"${git_sha}"'//')"
echo "Renaming ${f} to ${new_name}"
mv "${f}" "${new_name}"
done
- name: Release
uses: softprops/action-gh-release@v1
Expand All @@ -75,4 +97,4 @@ jobs:
draft: ${{ !startsWith(github.ref, 'refs/tags/') }}
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
files: |
./preevy-bin/**
packages/cli/dist/preevy-v*.tar.gz
31 changes: 0 additions & 31 deletions Dockerfile.cli

This file was deleted.

22 changes: 0 additions & 22 deletions packages/cli/.github/dependabot.yml

This file was deleted.

10 changes: 0 additions & 10 deletions packages/cli/.github/workflows/automerge.yml

This file was deleted.

43 changes: 0 additions & 43 deletions packages/cli/.github/workflows/failureNotifications.yml

This file was deleted.

36 changes: 0 additions & 36 deletions packages/cli/.github/workflows/manualRelease.yml

This file was deleted.

23 changes: 0 additions & 23 deletions packages/cli/.github/workflows/notify-slack-on-pr-open.yml

This file was deleted.

18 changes: 0 additions & 18 deletions packages/cli/.github/workflows/onPushToMain.yml

This file was deleted.

19 changes: 0 additions & 19 deletions packages/cli/.github/workflows/onRelease.yml

This file was deleted.

9 changes: 0 additions & 9 deletions packages/cli/.github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ oclif.manifest.json
*-debug.log
*-error.log
/.nyc_output
/tmp
2 changes: 1 addition & 1 deletion packages/cli/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.12.1
v18.19.0
2 changes: 1 addition & 1 deletion packages/cli/bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\dev.js" %*
node --enable-source-maps --no-warnings=ExperimentalWarning "%~dp0\dev.js" %*
2 changes: 1 addition & 1 deletion packages/cli/bin/dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S NODE_OPTIONS=--no-warnings=ExperimentalWarning\_--experimental-specifier-resolution=node ts-node --esm --swc
#!/usr/bin/env -S NODE_OPTIONS=--no-warnings=ExperimentalWarning\_--enable-source-maps=\_--experimental-specifier-resolution=node ts-node --esm --swc
// eslint-disable-next-line node/shebang
async function main() {
await import('disposablestack/auto')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\run.js" %*
node --enable-source-maps --no-warnings=ExperimentalWarning "%~dp0\run.js" %*
2 changes: 1 addition & 1 deletion packages/cli/bin/run.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning --enable-source-maps
async function main() {
await import('disposablestack/auto')
const {execute} = await import('@oclif/core')
Expand Down
Loading

0 comments on commit b966819

Please sign in to comment.