From ecc6f4eaf19187e1f7340bbc5dcf7cfd6a189b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Thu, 9 Jun 2022 13:44:01 +0200 Subject: [PATCH] Add package step again We still need this... --- .eslintignore | 1 + .github/workflows/release.yml | 27 +++++++++++++++++++++------ .github/workflows/test.yml | 1 + .gitignore | 3 ++- action.yml | 2 +- package-lock.json | 16 ++++++++++++++++ package.json | 10 ++++++---- 7 files changed, 48 insertions(+), 12 deletions(-) diff --git a/.eslintignore b/.eslintignore index c2658d7..1eae0cf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ +dist/ node_modules/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71ee982..33faae9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,8 +13,22 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Rebuild dist + id: dist + run: | + npm install + npm run package + git config user.name github-actions + git config user.email github-actions@github.com + git add --force dist/index.js + (git commit -m 'Publish dist' && echo '::set-output name=changed::true') || echo '::set-output name=changed::false' + - name: Push rebuild dist + if: ${{ steps.dist.outputs.changed == 'true' }} + run: | + git push origin main - name: Bump version and push tag uses: anothrNick/github-tag-action@1.39.0 + if: ${{ steps.dist.outputs.changed == 'true' }} id: version env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -22,24 +36,25 @@ jobs: DEFAULT_BUMP: patch - name: Major version tag id: major-version - if: ${{ (steps.version.outputs.new_tag != '') }} + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} uses: actions/github-script@v6 with: script: | core.setOutput('tag', '${{ steps.version.outputs.new_tag }}'.split('.')[0]) - name: Tag ${{ steps.major-version.outputs.tag }} - if: ${{ (steps.version.outputs.new_tag != '') }} + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} run: | git tag --force ${{ steps.major-version.outputs.tag }} git push origin ${{ steps.major-version.outputs.tag }} --force - name: Get current date + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} id: date run: echo "::set-output name=date::$(date --iso-8601)" - name: Build full ChangeLog - if: ${{ (steps.version.outputs.new_tag != '') }} + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} run: npx conventional-changelog-cli --release-count=0 --preset=eslint --outfile="${{ runner.temp }}/FullChangeLog.md" - name: Create/update major version release - if: ${{ (steps.version.outputs.new_tag != '') }} + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} uses: ncipollo/release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -48,10 +63,10 @@ jobs: name: ${{ steps.version.outputs.new_tag }} (${{ steps.date.outputs.date }}) bodyFile: ${{ runner.temp }}/FullChangeLog.md - name: Build ChangeLog - if: ${{ (steps.version.outputs.new_tag != '') }} + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} run: npx conventional-changelog-cli --release-count=2 --outfile="${{ runner.temp }}/ChangeLog.md" - name: Create release - if: ${{ (steps.version.outputs.new_tag != '') }} + if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} uses: ncipollo/release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de1fdc2..6c98bc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: - uses: actions/checkout@v3 - run: | npm install + npm run package - uses: ./ id: go-version-1 with: diff --git a/.gitignore b/.gitignore index 18e337d..f7faa6b 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,5 @@ Thumbs.db # Ignore built ts files __tests__/runner/* -lib/**/* \ No newline at end of file + +dist/ diff --git a/action.yml b/action.yml index d82fd86..6c6fb9e 100644 --- a/action.yml +++ b/action.yml @@ -33,4 +33,4 @@ outputs: description: The go module path (as specified by go.mod) runs: using: node16 - main: src/main.js + main: dist/index.js diff --git a/package-lock.json b/package-lock.json index 614358c..898527c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.18.2", + "@vercel/ncc": "^0.34.0", "babel-jest": "^28.1.1", "eslint": "^8.17.0", "eslint-plugin-github": "^4.3.6", @@ -2878,6 +2879,15 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@vercel/ncc": { + "version": "0.34.0", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz", + "integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==", + "dev": true, + "bin": { + "ncc": "dist/ncc/cli.js" + } + }, "node_modules/acorn": { "version": "8.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", @@ -10381,6 +10391,12 @@ "eslint-visitor-keys": "^3.3.0" } }, + "@vercel/ncc": { + "version": "0.34.0", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz", + "integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==", + "dev": true + }, "acorn": { "version": "8.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", diff --git a/package.json b/package.json index 0dad8d8..4446c2f 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,15 @@ "name": "go-version-action", "private": true, "description": "Go Version action", - "main": "src/index.js", + "main": "src/main.js", "scripts": { "format": "prettier --write **/*.js", "format-check": "prettier --check **/*.js", - "lint": "eslint **/*.js", - "lint-fix": "eslint --fix **/*.js", + "lint": "eslint .", + "lint-fix": "eslint --fix .", "test": "jest", - "all": "npm run format && npm run lint && npm test" + "package": "ncc build --minify", + "all": "npm run format && npm run lint && npm run package && npm test" }, "type": "module", "keywords": [ @@ -25,6 +26,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.18.2", + "@vercel/ncc": "^0.34.0", "babel-jest": "^28.1.1", "eslint": "^8.17.0", "eslint-plugin-github": "^4.3.6",