Skip to content

Commit

Permalink
ci: deploy (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
xc2 authored Oct 8, 2024
1 parent 077ac4c commit cafd254
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/ci-deploy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

if [[ ! "$GITHUB_REF_TYPE" = "tag" ]]; then
echo "Not a tag. Skipping deployment." >&2
exit 1
fi

EXTENSION_VERSION=${GITHUB_REF_NAME#v}

if [[ -z "$EXTENSION_VERSION" ]]; then
echo "Could not determine extension version from tag name." >&2
exit 2
fi

echo "Building extension version $EXTENSION_VERSION..."

rm -rf dist *.zip
env "EXTENSION_VERSION=$EXTENSION_VERSION" pnpm vite build
cd dist
zip -r "../follow-it-later.v${EXTENSION_VERSION}.zip" .
27 changes: 27 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release
on:
workflow_dispatch:
release:
types:
- published

jobs:
build:
uses: xc2/ghwf/.github/workflows/pnpm-artifact.yaml@main
with:
script: ci-deploy
artifact-path: "*.zip"
artifact-name: pkg

update-release:
needs: build
uses: xc2/ghwf/.github/workflows/update-release.yaml@main
if: startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
contents: write
attestations: write
with:
cache-key: ${{ needs.build.outputs.cache-key }}
cache-path: ${{ needs.build.outputs.cache-path }}
provenance: true
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"build": "vite build",
"build:watch": "vite build --watch",
"start": "vite dev",
"deploy": "rm -rf dist follow-it-later.zip && vite build && cd dist && zip -r ../follow-it-later.zip ."
"deploy": "rm -rf dist follow-it-later.zip && vite build && cd dist && zip -r ../follow-it-later.zip .",
"ci-deploy": "./.github/ci-deploy.bash"
},
"nano-staged": {
"*.{js,ts,tsx,mjs,mts,css,json,cjs,cts}": "biome check --write --diagnostic-level=error --no-errors-on-unmatched"
Expand Down

0 comments on commit cafd254

Please sign in to comment.