diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..671f3d6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + # Step 1 : Check repository + - name: Checkout repository + uses: actions/checkout@v3 + + # Step 2 : Config Node.js + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + # Step 3 : install and build + - name: Install dependencies + run: npm install + + - name: Authenticate to NPM + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc + + # Step 4 : Get local version + - name: Get version from NPM + id: get_npm_version + run: | + PACKAGE_NAME="mytril" + NPM_VERSION=$(npm show $PACKAGE_NAME version || echo "0.0.0") + echo "npm_version=$NPM_VERSION" >> $GITHUB_ENV + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + + # Step 5 : Verify version on NPM + - name: Compare versions + id: compare_versions + run: | + LOCAL_VERSION=$(node -p "require('./package.json').version") + echo "Local version: $LOCAL_VERSION" + echo "NPM version: $NPM_VERSION" + + if [ "$LOCAL_VERSION" = "$NPM_VERSION" ]; then + echo "Local version is equal to NPM version. Skipping publication." + exit 0 + fi + + if [ "$(printf '%s\n' "$NPM_VERSION" "$LOCAL_VERSION" | sort -V | tail -n1)" != "$LOCAL_VERSION" ]; then + echo "Local version is not greater than NPM version. Skipping publication." + exit 0 + else + echo "Local version is greater than NPM version. Proceeding to publish." + fi + + env: + NPM_VERSION: ${{ env.npm_version }} + + # Step 6: Publish on NPM + - name: Publish to NPM + if: steps.compare_versions.outcome == 'success' + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 77b4a3a..8a932c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.4.14] - 2025-01-25 + +### Added + +- Add first CLI for publish mytril ! + ## [0.4.13] - 2025-01-02 ### Added diff --git a/package.json b/package.json index bb118dd..959332c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mytril", "description": "Mytril Svelte library component for rapidly building modern websites based on Svelte and Sveltekit", - "version": "0.4.13", + "version": "0.4.14", "author": { "name": "Nycolaide", "email": "laurent.grimaldi@minedelve.com" diff --git a/src/components/app/app.legacy.svelte b/src/components/app/app.legacy.svelte new file mode 100644 index 0000000..ef35e43 --- /dev/null +++ b/src/components/app/app.legacy.svelte @@ -0,0 +1,39 @@ + + + + + + + diff --git a/src/components/app/app.svelte b/src/components/app/app.svelte index ef35e43..ea45873 100644 --- a/src/components/app/app.svelte +++ b/src/components/app/app.svelte @@ -1,39 +1,41 @@ - + + + + +{@render children()} - - - + diff --git a/src/components/app/app.svelte.ts b/src/components/app/app.svelte.ts new file mode 100644 index 0000000..e8ed0ad --- /dev/null +++ b/src/components/app/app.svelte.ts @@ -0,0 +1,20 @@ +// import { contextMytrilTheme } from '$lib/contexts/theme.svelte.js'; +import { getAllContexts, setContext } from 'svelte'; + +export function mytrilContext() { + const contexts = getAllContexts(); + + // contextMytrilTheme(); + + $effect.pre(() => { + console.log('contexts', contexts); + }); + + const inital = (config: object) => { + setContext('mytril', config); + }; + + return { + inital + }; +} diff --git a/src/contexts/theme.svelte.ts b/src/contexts/theme.svelte.ts new file mode 100644 index 0000000..468244f --- /dev/null +++ b/src/contexts/theme.svelte.ts @@ -0,0 +1,28 @@ +export const createTheme = () => { + let current = $state('light'); + + const update = (theme: string) => { + current = theme; + localStorage.setItem('@mytril:theme', theme); + }; + + const init = () => { + const theme = localStorage.getItem('@mytril:theme'); + + if (theme === 'system') { + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) + current = 'dark'; + else current = 'light'; + } else if (theme) { + current = theme; + } + }; + + return { + update, + init, + get current() { + return current; + } + }; +};