diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..af30937 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +dist/** -diff linguist-generated=true diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 121a0f5..cc9deac 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -12,15 +12,14 @@ on: paths-ignore: - '**.md' +permissions: + contents: read + jobs: check-dist: name: Check dist/ runs-on: ubuntu-latest - permissions: - contents: read - statuses: write - steps: - name: Checkout id: checkout @@ -30,7 +29,7 @@ jobs: id: setup-node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: .node-version cache: npm - name: Install Dependencies diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 7752b6d..8300a08 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -7,7 +7,6 @@ on: branches: - main -# This is required to be able to update tags and create releases permissions: contents: write @@ -16,18 +15,17 @@ jobs: name: Release Version runs-on: ubuntu-latest - # Only run this job if the PR was merged - if: ${{ github.event.pull_request.merged == true }} + if: | + github.event.pull_request.merged == true && + startsWith(github.head_ref, 'dependabot/') == false steps: - # Checkout the repository with fetch-tags set to true - name: Checkout id: checkout uses: actions/checkout@v4 with: fetch-tags: true - # Get the version and update the tags to use in the release - name: Tag id: tag uses: issue-ops/semver@v0.1.0 @@ -36,8 +34,6 @@ jobs: workspace: ${{ github.workspace }} ref: main - # Use the version output from the previous step for the release - # Prepend a 'v' to the beginning (e.g. 'v1.2.3') - name: Create Release id: release uses: issue-ops/releaser@v0.1.2 diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f2c6703..86f6a2d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -8,17 +8,16 @@ on: branches: - main +permissions: + actions: read + checks: write + contents: read + jobs: continuous-integration: name: Continuous Integration runs-on: ubuntu-latest - permissions: - actions: read - checks: write - contents: read - statuses: write - steps: - name: Checkout id: checkout @@ -28,7 +27,7 @@ jobs: id: setup-node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: .node-version cache: npm - name: Install Dependencies diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index 31542a1..cca916d 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -27,9 +27,9 @@ jobs: - name: Setup Node.js id: setup-node - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: - node-version: 20 + node-version-file: .node-version cache: npm - name: Install Dependencies diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..c48f715 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +20.6.0 \ No newline at end of file diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index f9e7b95..10781d9 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -5,9 +5,15 @@ import * as main from '../src/main' // Mock the action's entrypoint -const runMock = jest.spyOn(main, 'run').mockImplementation() +let runMock: jest.SpyInstance describe('index', () => { + beforeEach(() => { + jest.clearAllMocks() + + runMock = jest.spyOn(main, 'run').mockImplementation() + }) + it('calls run when imported', async () => { require('../src/index') diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 1eaf98e..91cf39b 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -6,12 +6,12 @@ import * as core from '@actions/core' import * as main from '../src/main' // Mock the GitHub Actions core library -const getInputMock = jest.spyOn(core, 'getInput').mockImplementation() -const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation() -const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation() +let getInputMock: jest.SpyInstance +let setFailedMock: jest.SpyInstance +let setOutputMock: jest.SpyInstance // Mock the action's main function -const runMock = jest.spyOn(main, 'run') +let runMock: jest.SpyInstance // Mock Octokit jest.mock('@octokit/rest', () => ({ @@ -21,6 +21,12 @@ jest.mock('@octokit/rest', () => ({ describe('action', () => { beforeEach(() => { jest.clearAllMocks() + + getInputMock = jest.spyOn(core, 'getInput').mockImplementation() + setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation() + setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation() + + runMock = jest.spyOn(main, 'run') }) it('reads valid inputs', async () => { diff --git a/package-lock.json b/package-lock.json index 4a34d2f..6a817a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "releaser", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "releaser", - "version": "0.1.2", + "version": "0.1.3", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", diff --git a/package.json b/package.json index 77b747d..ea51634 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "releaser", "description": "Handle releases for GitHub repositories", - "version": "0.1.2", + "version": "0.1.3", "author": "Nick Alteen ", "homepage": "https://github.com/issue-ops/releaser#readme", "repository": { @@ -25,13 +25,14 @@ "scripts": { "bundle": "npm run format:write && npm run package", "ci-test": "jest", + "coverage": "make-coverage-badge --output-path ./badges/coverage.svg", "format:write": "prettier --write '**/*.ts'", "format:check": "prettier --check '**/*.ts'", "lint": "npx eslint . -c ./.github/linters/.eslintrc.yml", "package": "ncc build src/index.ts -o dist --source-map --license licenses.txt", "package:watch": "npm run package -- --watch", - "test": "(jest && make-coverage-badge --output-path ./badges/coverage.svg) || make-coverage-badge --output-path ./badges/coverage.svg", - "all": "npm run format:write && npm run lint && npm run test && npm run package" + "test": "jest", + "all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package" }, "license": "MIT", "jest": {