diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75e2b86..1c47658 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,4 +19,45 @@ jobs: uses: helsingborg-stad/release-wp-plugin-action@1.0.2 with: php-version: 8.2 - node-version: 20.6.0 \ No newline at end of file + node-version: 20.6.0 + build-assets: + needs: ['release'] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Get latest release version + id: get-version + run: | + echo "LATEST_RELEASE=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')" >> $GITHUB_ENV + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Update version in package.json + run: | + # Read the latest release version from environment variable + LATEST_VERSION="${{ env.LATEST_RELEASE }}" + + # Update the "version" field in package.json using jq + jq --arg version "$LATEST_VERSION" '.version = $version' package.json > temp.json && mv temp.json package.json + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: 'https://npm.pkg.github.com/' + - name: Inject access token in .npmrc + run: | + echo "registry=https://npm.pkg.github.com/helsingborg-stad" >> ~/.npmrc + echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc + - name: Run CI + if: ${{ hashFiles('package.json') != '' && hashFiles('package-lock.json') != '' }} + run: npm ci --no-progress --no-audit + - name: Run build + if: ${{ hashFiles('package-lock.json') != '' && hashFiles('gulp.js') == '' }} + run: npx --yes browserslist@latest --update-db && npm run build + - name: Publish npm package to GHCR + run: npm publish --registry=https://npm.pkg.github.com + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 980fc14..9369656 100644 --- a/package-lock.json +++ b/package-lock.json @@ -701,9 +701,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001600", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001600.tgz", - "integrity": "sha512-+2S9/2JFhYmYaDpZvo0lKkfvuKIglrx68MwOBqMGHhQsNkLjB5xtc/TGoEPs+MxjSyN/72qer2g97nzR641mOQ==", + "version": "1.0.30001660", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001660.tgz", + "integrity": "sha512-GacvNTTuATm26qC74pt+ad1fW15mlQ/zuTzzY1ZoIzECTP8HURDfF43kNxPgf7H1jmelCBQTTbBNxdSXOA7Bqg==", "dev": true, "funding": [ { @@ -718,7 +718,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "license": "CC-BY-4.0" }, "node_modules/chalk": { "version": "2.4.2", diff --git a/package.json b/package.json index 87679bd..631c1db 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "lix-calculator", + "name": "@helsingborg-stad/lix-calculator", "version": "4.1.1", "description": "", "main": "", @@ -10,7 +10,7 @@ "author": "Helsingborg Stad", "license": "MIT", "bugs": { - "url": "" + "url": "https://github.com/helsingborg-stad/lix-calculator/issues" }, "homepage": "https://github.com/helsingborg-stad/lix-calculator", "scripts": { @@ -23,6 +23,7 @@ "> 1%", "not dead" ], + "files": ["dist/"], "devDependencies": { "autoprefixer": "^10.4.2", "clean-webpack-plugin": "^4.0.0", @@ -56,4 +57,4 @@ "@babel/plugin-proposal-class-properties" ] } -} \ No newline at end of file +}