Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): add nightly builds, rename zips #509

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Environment setup
description: Sets up Node and pnpm

runs:
using: 'composite'
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/nightly-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Nightly build

on:
schedule:
- cron: '0 0 * * 1-6'
workflow_dispatch:
inputs: {}

permissions:
contents: write

defaults:
run:
shell: bash

jobs:
build-nightly:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Environment setup
uses: ./.github/actions/setup

- name: Build
id: build
run: |
pnpm build
sidvishnoi marked this conversation as resolved.
Show resolved Hide resolved
echo "VERSION=$(jq -r '.version' './dist/chrome/manifest.json')" >> $GITHUB_OUTPUT

- name: Delete existing release
run: gh release delete nightly --cleanup-tag --yes
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}

- name: Create GH Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.zip
tag_name: 'nightly'
name: Nightly ${{ steps.build.outputs.VERSION }}
prerelease: true
1 change: 1 addition & 0 deletions cspell-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data-testid
nums

# scripts and 3rd party terms
nvmrc
typecheck
prettiercache
corepack
Expand Down
28 changes: 23 additions & 5 deletions esbuild/prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createWriteStream } from 'node:fs'
import path from 'node:path'
import type { BuildOptions, Plugin as ESBuildPlugin } from 'esbuild'
import archiver from 'archiver'
import type { BuildArgs } from './config'
import type { BuildArgs, Channel, Target, WebExtensionManifest } from './config'
import { getPlugins } from './plugins'
import { typecheckPlugin } from '@jgoz/esbuild-plugin-typecheck'

Expand All @@ -22,7 +22,7 @@ export const getProdOptions = ({
plugins: getPlugins({ outDir, dev: false, target, channel }).concat([
typecheckPlugin({ buildMode: 'readonly' }),
preservePolyfillClassNamesPlugin({ outDir }),
zipPlugin({ outDir })
zipPlugin({ outDir, target, channel })
]),
define: {
NODE_ENV: JSON.stringify('production'),
Expand All @@ -36,16 +36,34 @@ export const getProdOptions = ({
}
}

function zipPlugin({ outDir }: { outDir: string }): ESBuildPlugin {
function zipPlugin({
outDir,
target,
channel
}: {
channel: Channel
target: Target
outDir: string
}): ESBuildPlugin {
return {
name: 'zip',
setup(build) {
build.onEnd(async () => {
const output = createWriteStream(`${outDir}.zip`)
const manifest = JSON.parse(
await fs.readFile(path.join(outDir, 'manifest.json'), 'utf8')
) as WebExtensionManifest

let zipName = `${target}-${manifest.version}.zip`
if (channel !== 'stable') {
zipName = `${channel}-${zipName}`
}

const dest = path.join(outDir, '..', zipName)
const output = createWriteStream(dest)
const archive = archiver('zip')
archive.on('end', function () {
const archiveSize = archive.pointer()
const fileName = path.relative(process.cwd(), `${outDir}.zip`)
const fileName = path.relative(process.cwd(), dest)
console.log(` Archived ${fileName}: ${formatBytes(archiveSize)}`)
})
archive.pipe(output)
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/chrome-manifest",
"name": "__MSG_appName__",
"version": "0.1.1",
"version": "0.1.1.0",
"manifest_version": 3,
"minimum_chrome_version": "110.0",
"description": "__MSG_appDescription__",
Expand Down