diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 048c2bf..bd97873 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,9 @@ jobs: build-assets: needs: ['release'] runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Get latest release version id: get-version @@ -32,10 +35,21 @@ jobs: 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.6.0 + - 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 @@ -48,6 +62,10 @@ jobs: - name: Run gulp if: ${{ hashFiles('package-lock.json') != '' && hashFiles('gulp.js') != '' }} run: gulp + - name: Publish npm package to GHCR + run: npm publish --registry=https://npm.pkg.github.com + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create assets zip uses: thedoctor0/zip-release@0.7.5 if: ${{ hashFiles('dist/') != '' }} diff --git a/.gitignore b/.gitignore index 3a8d9d1..574d1d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -# ignore all files starting with . or ~ -.* -~* - # ignore node/grunt dependency directories node_modules/ vendor/ diff --git a/package-lock.json b/package-lock.json index c20eb30..59a71e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "algolia-index-js-searchpage-addon", + "name": "@helsingborg-stad/algolia-index-js-searchpage-addon", "version": "3.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "algolia-index-js-searchpage-addon", + "name": "@helsingborg-stad/algolia-index-js-searchpage-addon", "version": "3.2.0", "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 106798a..2adabe2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "algolia-index-js-searchpage-addon", + "name": "@helsingborg-stad/algolia-index-js-searchpage-addon", "version": "3.2.0", "description": "Childtheme for Municipio theme", "author": "Sebastian Thulin", @@ -14,6 +14,9 @@ "> 1%", "not dead" ], + "files": [ + "assets/" + ], "devDependencies": { "@babel/core": "^7.17.2", "@babel/plugin-proposal-class-properties": "^7.16.7",