Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9128f238ee | ||
|
|
7922049688 | ||
|
|
0683ea3557 | ||
|
|
01c9fac73b | ||
|
|
90dc22b77f | ||
|
|
10585cb926 | ||
|
|
1896b4fc46 | ||
|
|
6996c1bc95 | ||
|
|
c07d979560 | ||
|
|
38da029bb7 | ||
|
|
bf17a40975 | ||
|
|
fa4749311e | ||
|
|
36e78ab629 | ||
|
|
6c1f9baed2 | ||
|
|
db62f3f3ad | ||
|
|
e6992e14b1 | ||
|
|
440c8c1cb0 | ||
|
|
e805702217 | ||
|
|
bd572a1942 | ||
|
|
706b28e44c | ||
|
|
411ac011df | ||
|
|
a8c5a7f252 | ||
|
|
62f16c02e7 | ||
|
|
00e83e3d35 | ||
|
|
906fc77113 | ||
|
|
17b559883e | ||
|
|
33bf18d283 | ||
|
|
009df9782d | ||
|
|
4b84ad5c60 | ||
|
|
34dae7e8c0 | ||
|
|
9fc271e109 | ||
|
|
3cfa40eca4 |
22
.github/workflows/release.yml
vendored
Normal file
22
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
create_release:
|
||||
if: github.ref != 'refs/tags/v1'
|
||||
runs-on: ubuntu-latest
|
||||
name: Create Release
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
allowUpdates: true
|
||||
draft: true
|
||||
generateReleaseNotes: true
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
node_modules/
|
||||
__tests__/runner/*
|
||||
.DS_Store
|
||||
|
||||
# Created by https://www.gitignore.io/api/webstorm
|
||||
# Edit at https://www.gitignore.io/?templates=webstorm
|
||||
@@ -98,4 +99,4 @@ fabric.properties
|
||||
coverage
|
||||
|
||||
# Ignore lib, it contains intermediates
|
||||
/lib
|
||||
/lib
|
||||
|
||||
6
.idea/biome.xml
generated
Normal file
6
.idea/biome.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BiomeSettings">
|
||||
<option name="enableLspFormat" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -48,7 +48,9 @@ This action will create a GitHub release and optionally upload an artifact to it
|
||||
|-------------|-----------------------------------------------|
|
||||
| id | The identifier of the created release. |
|
||||
| html_url | The HTML URL of the release. |
|
||||
| upload_url | The URL for uploading assets to the release. |
|
||||
| upload_url | The URL for [uploading assets](https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset) to the release. |
|
||||
| tarball_url | The URL for downloading the release as a tarball (.tar.gz). |
|
||||
| zipball_url | The URL for downloading the release as a zipball (.zip). |
|
||||
|
||||
## Example
|
||||
This example will create a release when a tag is pushed:
|
||||
@@ -68,7 +70,7 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
artifacts: "release.tar.gz,foo/*.txt"
|
||||
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
artifacts: "release.tar.gz,foo/*.txt"
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import {Action} from "../src/Action";
|
||||
import {Artifact} from "../src/Artifact";
|
||||
import {Inputs} from "../src/Inputs";
|
||||
import {Releases} from "../src/Releases";
|
||||
import {ArtifactUploader} from "../src/ArtifactUploader";
|
||||
import {Outputs} from "../src/Outputs";
|
||||
import {ArtifactDestroyer} from "../src/ArtifactDestroyer";
|
||||
import {ActionSkipper} from "../src/ActionSkipper";
|
||||
import { Action } from "../src/Action"
|
||||
import type { ActionSkipper } from "../src/ActionSkipper"
|
||||
import { Artifact } from "../src/Artifact"
|
||||
import type { ArtifactDestroyer } from "../src/ArtifactDestroyer"
|
||||
import type { ArtifactUploader } from "../src/ArtifactUploader"
|
||||
import type { Inputs } from "../src/Inputs"
|
||||
import type { Outputs } from "../src/Outputs"
|
||||
import type { Releases } from "../src/Releases"
|
||||
|
||||
const TEST_URLS = {
|
||||
UPLOAD_URL: "http://api.example.com",
|
||||
HTML_URL: "https://github.com/owner/repo/releases/tag/v1.0.0",
|
||||
TARBALL_URL: "https://api.github.com/repos/owner/repo/tarball/v1.0.0",
|
||||
ZIPBALL_URL: "https://api.github.com/repos/owner/repo/zipball/v1.0.0",
|
||||
} as const
|
||||
|
||||
const applyReleaseDataMock = jest.fn()
|
||||
const artifactDestroyMock = jest.fn()
|
||||
@@ -17,31 +24,30 @@ const listMock = jest.fn()
|
||||
const shouldSkipMock = jest.fn()
|
||||
const updateMock = jest.fn()
|
||||
const uploadMock = jest.fn()
|
||||
const genReleaseNotesMock = jest.fn()
|
||||
|
||||
const artifacts = [
|
||||
new Artifact('a/art1'),
|
||||
new Artifact('b/art2')
|
||||
]
|
||||
const artifacts = [new Artifact("a/art1"), new Artifact("b/art2")]
|
||||
|
||||
const createBody = 'createBody'
|
||||
const createBody = "createBody"
|
||||
const createDraft = true
|
||||
const createName = 'createName'
|
||||
const commit = 'commit'
|
||||
const discussionCategory = 'discussionCategory'
|
||||
const createName = "createName"
|
||||
const commit = "commit"
|
||||
const discussionCategory = "discussionCategory"
|
||||
const generateReleaseNotes = true
|
||||
const id = 100
|
||||
const createPrerelease = true
|
||||
const releaseId = 101
|
||||
const replacesArtifacts = true
|
||||
const tag = 'tag'
|
||||
const token = 'token'
|
||||
const updateBody = 'updateBody'
|
||||
const tag = "tag"
|
||||
const token = "token"
|
||||
const updateBody = "updateBody"
|
||||
const updateDraft = false
|
||||
const updateName = 'updateName'
|
||||
const updateName = "updateName"
|
||||
const updatePrerelease = false
|
||||
const updateOnlyUnreleased = false
|
||||
const url = 'http://api.example.com'
|
||||
const makeLatest = 'legacy'
|
||||
const url = TEST_URLS.UPLOAD_URL
|
||||
const makeLatest = "legacy"
|
||||
const generatedReleaseBody = "test release notes"
|
||||
|
||||
describe("Action", () => {
|
||||
beforeEach(() => {
|
||||
@@ -53,32 +59,12 @@ describe("Action", () => {
|
||||
uploadMock.mockClear()
|
||||
})
|
||||
|
||||
it('creates release but does not upload if no artifact', async () => {
|
||||
it("creates release but does not upload if no artifact", async () => {
|
||||
const action = createAction(false, false)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(createMock).toBeCalledWith(tag,
|
||||
createBody,
|
||||
commit,
|
||||
discussionCategory,
|
||||
createDraft,
|
||||
generateReleaseNotes,
|
||||
makeLatest,
|
||||
createName,
|
||||
createPrerelease)
|
||||
expect(uploadMock).not.toBeCalled()
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('creates release if no release exists to update', async () => {
|
||||
const action = createAction(true, true)
|
||||
const error = {status: 404}
|
||||
getMock.mockRejectedValue(error)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(createMock).toBeCalledWith(
|
||||
expect(createMock).toHaveBeenCalledWith(
|
||||
tag,
|
||||
createBody,
|
||||
commit,
|
||||
@@ -87,24 +73,45 @@ describe("Action", () => {
|
||||
generateReleaseNotes,
|
||||
makeLatest,
|
||||
createName,
|
||||
createPrerelease)
|
||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||
createPrerelease
|
||||
)
|
||||
expect(uploadMock).not.toHaveBeenCalled()
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('creates release if no draft releases', async () => {
|
||||
it("creates release if no release exists to update", async () => {
|
||||
const action = createAction(true, true)
|
||||
const error = {status: 404}
|
||||
const error = { status: 404 }
|
||||
getMock.mockRejectedValue(error)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(createMock).toHaveBeenCalledWith(
|
||||
tag,
|
||||
createBody,
|
||||
commit,
|
||||
discussionCategory,
|
||||
createDraft,
|
||||
generateReleaseNotes,
|
||||
makeLatest,
|
||||
createName,
|
||||
createPrerelease
|
||||
)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it("creates release if no draft releases", async () => {
|
||||
const action = createAction(true, true)
|
||||
const error = { status: 404 }
|
||||
getMock.mockRejectedValue(error)
|
||||
listMock.mockResolvedValue({
|
||||
data: [
|
||||
{id: id, draft: false, tag_name: tag}
|
||||
]
|
||||
data: [{ id: id, draft: false, tag_name: tag }],
|
||||
})
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(createMock).toBeCalledWith(
|
||||
expect(createMock).toHaveBeenCalledWith(
|
||||
tag,
|
||||
createBody,
|
||||
commit,
|
||||
@@ -115,17 +122,16 @@ describe("Action", () => {
|
||||
createName,
|
||||
createPrerelease
|
||||
)
|
||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
|
||||
})
|
||||
|
||||
it('creates release then uploads artifact', async () => {
|
||||
it("creates release then uploads artifact", async () => {
|
||||
const action = createAction(false, true)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(createMock).toBeCalledWith(
|
||||
expect(createMock).toHaveBeenCalledWith(
|
||||
tag,
|
||||
createBody,
|
||||
commit,
|
||||
@@ -136,39 +142,39 @@ describe("Action", () => {
|
||||
createName,
|
||||
createPrerelease
|
||||
)
|
||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('removes all artifacts when artifact destroyer is enabled', async () => {
|
||||
it("removes all artifacts when artifact destroyer is enabled", async () => {
|
||||
const action = createAction(false, true, true)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(artifactDestroyMock).toBeCalledWith(releaseId)
|
||||
expect(artifactDestroyMock).toHaveBeenCalledWith(releaseId)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('removes no artifacts when artifact destroyer is disabled', async () => {
|
||||
it("removes no artifacts when artifact destroyer is disabled", async () => {
|
||||
const action = createAction(false, true)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(artifactDestroyMock).not.toBeCalled()
|
||||
expect(artifactDestroyMock).not.toHaveBeenCalled()
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('skips action', async () => {
|
||||
it("skips action", async () => {
|
||||
const action = createAction(false, false, false)
|
||||
shouldSkipMock.mockResolvedValue(true)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(createMock).not.toBeCalled()
|
||||
expect(updateMock).not.toBeCalled()
|
||||
expect(createMock).not.toHaveBeenCalled()
|
||||
expect(updateMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('throws error when create fails', async () => {
|
||||
it("throws error when create fails", async () => {
|
||||
const action = createAction(false, true)
|
||||
createMock.mockRejectedValue("error")
|
||||
|
||||
@@ -179,7 +185,7 @@ describe("Action", () => {
|
||||
expect(error).toEqual("error")
|
||||
}
|
||||
|
||||
expect(createMock).toBeCalledWith(
|
||||
expect(createMock).toHaveBeenCalledWith(
|
||||
tag,
|
||||
createBody,
|
||||
commit,
|
||||
@@ -190,17 +196,17 @@ describe("Action", () => {
|
||||
createName,
|
||||
createPrerelease
|
||||
)
|
||||
expect(uploadMock).not.toBeCalled()
|
||||
expect(uploadMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('throws error when get fails', async () => {
|
||||
it("throws error when get fails", async () => {
|
||||
const action = createAction(true, true)
|
||||
const error = {
|
||||
errors: [
|
||||
{
|
||||
code: 'already_exists'
|
||||
}
|
||||
]
|
||||
code: "already_exists",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
createMock.mockRejectedValue(error)
|
||||
@@ -212,22 +218,20 @@ describe("Action", () => {
|
||||
expect(error).toEqual("error")
|
||||
}
|
||||
|
||||
expect(getMock).toBeCalledWith(tag)
|
||||
expect(updateMock).not.toBeCalled()
|
||||
expect(uploadMock).not.toBeCalled()
|
||||
|
||||
expect(getMock).toHaveBeenCalledWith(tag)
|
||||
expect(updateMock).not.toHaveBeenCalled()
|
||||
expect(uploadMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('throws error when list has no data', async () => {
|
||||
|
||||
it("throws error when list has no data", async () => {
|
||||
const action = createAction(true, true)
|
||||
getMock.mockRejectedValue({status: 404})
|
||||
getMock.mockRejectedValue({ status: 404 })
|
||||
const error = {
|
||||
errors: [
|
||||
{
|
||||
code: 'already_exists'
|
||||
}
|
||||
]
|
||||
code: "already_exists",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
createMock.mockRejectedValue(error)
|
||||
@@ -239,12 +243,12 @@ describe("Action", () => {
|
||||
expect(error).toEqual(Error("No releases found. Response: {}"))
|
||||
}
|
||||
|
||||
expect(listMock).toBeCalled()
|
||||
expect(createMock).not.toBeCalled()
|
||||
expect(updateMock).not.toBeCalled()
|
||||
expect(listMock).toHaveBeenCalled()
|
||||
expect(createMock).not.toHaveBeenCalled()
|
||||
expect(updateMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('throws error when update fails', async () => {
|
||||
it("throws error when update fails", async () => {
|
||||
const action = createAction(true, true)
|
||||
|
||||
updateMock.mockRejectedValue("error")
|
||||
@@ -256,10 +260,10 @@ describe("Action", () => {
|
||||
expect(error).toEqual("error")
|
||||
}
|
||||
|
||||
expect(updateMock).toBeCalledWith(
|
||||
expect(updateMock).toHaveBeenCalledWith(
|
||||
id,
|
||||
tag,
|
||||
updateBody,
|
||||
generatedReleaseBody,
|
||||
commit,
|
||||
discussionCategory,
|
||||
updateDraft,
|
||||
@@ -267,12 +271,12 @@ describe("Action", () => {
|
||||
updateName,
|
||||
updatePrerelease
|
||||
)
|
||||
expect(uploadMock).not.toBeCalled()
|
||||
expect(uploadMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('throws error when upload fails', async () => {
|
||||
it("throws error when upload fails", async () => {
|
||||
const action = createAction(false, true)
|
||||
const expectedError = {status: 404}
|
||||
const expectedError = { status: 404 }
|
||||
uploadMock.mockRejectedValue(expectedError)
|
||||
|
||||
expect.hasAssertions()
|
||||
@@ -282,7 +286,7 @@ describe("Action", () => {
|
||||
expect(error).toEqual(expectedError)
|
||||
}
|
||||
|
||||
expect(createMock).toBeCalledWith(
|
||||
expect(createMock).toHaveBeenCalledWith(
|
||||
tag,
|
||||
createBody,
|
||||
commit,
|
||||
@@ -293,23 +297,51 @@ describe("Action", () => {
|
||||
createName,
|
||||
createPrerelease
|
||||
)
|
||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
})
|
||||
|
||||
it('updates draft release', async () => {
|
||||
it("updates draft release", async () => {
|
||||
const action = createAction(true, true)
|
||||
const error = {status: 404}
|
||||
const error = { status: 404 }
|
||||
getMock.mockRejectedValue(error)
|
||||
listMock.mockResolvedValue({
|
||||
data: [
|
||||
{id: 123, draft: false, tag_name: tag},
|
||||
{id: id, draft: true, tag_name: tag}
|
||||
]
|
||||
{ id: 123, draft: false, tag_name: tag },
|
||||
{ id: id, draft: true, tag_name: tag },
|
||||
],
|
||||
})
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(updateMock).toBeCalledWith(
|
||||
expect(updateMock).toHaveBeenCalledWith(
|
||||
id,
|
||||
tag,
|
||||
generatedReleaseBody,
|
||||
commit,
|
||||
discussionCategory,
|
||||
updateDraft,
|
||||
makeLatest,
|
||||
updateName,
|
||||
updatePrerelease
|
||||
)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it("updates draft release with static body", async () => {
|
||||
const action = createAction(true, true, false, false)
|
||||
const error = { status: 404 }
|
||||
getMock.mockRejectedValue(error)
|
||||
listMock.mockResolvedValue({
|
||||
data: [
|
||||
{ id: 123, draft: false, tag_name: tag },
|
||||
{ id: id, draft: true, tag_name: tag },
|
||||
],
|
||||
})
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(updateMock).toHaveBeenCalledWith(
|
||||
id,
|
||||
tag,
|
||||
updateBody,
|
||||
@@ -320,19 +352,19 @@ describe("Action", () => {
|
||||
updateName,
|
||||
updatePrerelease
|
||||
)
|
||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('updates release but does not upload if no artifact', async () => {
|
||||
it("updates release but does not upload if no artifact", async () => {
|
||||
const action = createAction(true, false)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(updateMock).toBeCalledWith(
|
||||
expect(updateMock).toHaveBeenCalledWith(
|
||||
id,
|
||||
tag,
|
||||
updateBody,
|
||||
generatedReleaseBody,
|
||||
commit,
|
||||
discussionCategory,
|
||||
updateDraft,
|
||||
@@ -340,16 +372,44 @@ describe("Action", () => {
|
||||
updateName,
|
||||
updatePrerelease
|
||||
)
|
||||
expect(uploadMock).not.toBeCalled()
|
||||
expect(uploadMock).not.toHaveBeenCalled()
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it('updates release then uploads artifact', async () => {
|
||||
it("updates release then uploads artifact", async () => {
|
||||
const action = createAction(true, true)
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(updateMock).toBeCalledWith(
|
||||
expect(updateMock).toHaveBeenCalledWith(
|
||||
id,
|
||||
tag,
|
||||
generatedReleaseBody,
|
||||
commit,
|
||||
discussionCategory,
|
||||
updateDraft,
|
||||
makeLatest,
|
||||
updateName,
|
||||
updatePrerelease
|
||||
)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
it("updates release with static body when generateReleaseNotes is true but omitBodyDuringUpdate is true", async () => {
|
||||
const action = createAction(true, true, false, true, true)
|
||||
const error = { status: 404 }
|
||||
getMock.mockRejectedValue(error)
|
||||
listMock.mockResolvedValue({
|
||||
data: [
|
||||
{ id: 123, draft: false, tag_name: tag },
|
||||
{ id: id, draft: true, tag_name: tag },
|
||||
],
|
||||
})
|
||||
|
||||
await action.perform()
|
||||
|
||||
expect(updateMock).toHaveBeenCalledWith(
|
||||
id,
|
||||
tag,
|
||||
updateBody,
|
||||
@@ -360,23 +420,35 @@ describe("Action", () => {
|
||||
updateName,
|
||||
updatePrerelease
|
||||
)
|
||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||
expect(uploadMock).toHaveBeenCalledWith(artifacts, releaseId, url)
|
||||
assertOutputApplied()
|
||||
})
|
||||
|
||||
function assertOutputApplied() {
|
||||
expect(applyReleaseDataMock).toBeCalledWith({id: releaseId, upload_url: url})
|
||||
expect(applyReleaseDataMock).toHaveBeenCalledWith({
|
||||
id: releaseId,
|
||||
upload_url: url,
|
||||
html_url: TEST_URLS.HTML_URL,
|
||||
tarball_url: TEST_URLS.TARBALL_URL,
|
||||
zipball_url: TEST_URLS.ZIPBALL_URL,
|
||||
})
|
||||
}
|
||||
|
||||
function createAction(allowUpdates: boolean,
|
||||
hasArtifact: boolean,
|
||||
removeArtifacts: boolean = false): Action {
|
||||
function createAction(
|
||||
allowUpdates: boolean,
|
||||
hasArtifact: boolean,
|
||||
removeArtifacts = false,
|
||||
generateReleaseNotes = true,
|
||||
omitBodyDuringUpdate = false
|
||||
): Action {
|
||||
let inputArtifact: Artifact[]
|
||||
|
||||
if (hasArtifact) {
|
||||
inputArtifact = artifacts
|
||||
} else {
|
||||
inputArtifact = []
|
||||
}
|
||||
|
||||
const MockReleases = jest.fn<Releases, any>(() => {
|
||||
return {
|
||||
create: createMock,
|
||||
@@ -385,79 +457,93 @@ describe("Action", () => {
|
||||
listArtifactsForRelease: listArtifactsMock,
|
||||
listReleases: listMock,
|
||||
update: updateMock,
|
||||
uploadArtifact: jest.fn()
|
||||
uploadArtifact: jest.fn(),
|
||||
generateReleaseNotes: genReleaseNotesMock,
|
||||
}
|
||||
})
|
||||
|
||||
createMock.mockResolvedValue({
|
||||
data: {
|
||||
id: releaseId,
|
||||
upload_url: url
|
||||
}
|
||||
upload_url: url,
|
||||
html_url: TEST_URLS.HTML_URL,
|
||||
tarball_url: TEST_URLS.TARBALL_URL,
|
||||
zipball_url: TEST_URLS.ZIPBALL_URL,
|
||||
},
|
||||
})
|
||||
|
||||
genReleaseNotesMock.mockResolvedValue({
|
||||
data: {
|
||||
body: generatedReleaseBody,
|
||||
},
|
||||
})
|
||||
getMock.mockResolvedValue({
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
listMock.mockResolvedValue({
|
||||
data: []
|
||||
data: [],
|
||||
})
|
||||
shouldSkipMock.mockResolvedValue(false)
|
||||
updateMock.mockResolvedValue({
|
||||
data: {
|
||||
id: releaseId,
|
||||
upload_url: url
|
||||
}
|
||||
upload_url: url,
|
||||
html_url: TEST_URLS.HTML_URL,
|
||||
tarball_url: TEST_URLS.TARBALL_URL,
|
||||
zipball_url: TEST_URLS.ZIPBALL_URL,
|
||||
},
|
||||
})
|
||||
uploadMock.mockResolvedValue({})
|
||||
|
||||
const MockInputs = jest.fn<Inputs, any>(() => {
|
||||
return {
|
||||
allowUpdates: allowUpdates,
|
||||
allowUpdates,
|
||||
artifactErrorsFailBuild: true,
|
||||
artifacts: inputArtifact,
|
||||
createdDraft: createDraft,
|
||||
createdReleaseBody: createBody,
|
||||
createdReleaseName: createName,
|
||||
commit: commit,
|
||||
discussionCategory: discussionCategory,
|
||||
generateReleaseNotes: true,
|
||||
commit,
|
||||
discussionCategory,
|
||||
generateReleaseNotes,
|
||||
makeLatest: makeLatest,
|
||||
owner: "owner",
|
||||
createdPrerelease: createPrerelease,
|
||||
replacesArtifacts: replacesArtifacts,
|
||||
removeArtifacts: removeArtifacts,
|
||||
replacesArtifacts,
|
||||
removeArtifacts,
|
||||
repo: "repo",
|
||||
skipIfReleaseExists: false,
|
||||
tag: tag,
|
||||
token: token,
|
||||
tag,
|
||||
token,
|
||||
updatedDraft: updateDraft,
|
||||
updatedReleaseBody: updateBody,
|
||||
updatedReleaseName: updateName,
|
||||
updatedPrerelease: updatePrerelease,
|
||||
updateOnlyUnreleased: updateOnlyUnreleased
|
||||
updateOnlyUnreleased: updateOnlyUnreleased,
|
||||
omitBodyDuringUpdate,
|
||||
}
|
||||
})
|
||||
const MockOutputs = jest.fn<Outputs, any>(() => {
|
||||
return {
|
||||
applyReleaseData: applyReleaseDataMock
|
||||
applyReleaseData: applyReleaseDataMock,
|
||||
}
|
||||
})
|
||||
const MockUploader = jest.fn<ArtifactUploader, any>(() => {
|
||||
return {
|
||||
uploadArtifacts: uploadMock
|
||||
uploadArtifacts: uploadMock,
|
||||
}
|
||||
})
|
||||
const MockArtifactDestroyer = jest.fn<ArtifactDestroyer, any>(() => {
|
||||
return {
|
||||
destroyArtifacts: artifactDestroyMock
|
||||
destroyArtifacts: artifactDestroyMock,
|
||||
}
|
||||
})
|
||||
|
||||
const MockActionSkipper = jest.fn<ActionSkipper, any>(() => {
|
||||
return {
|
||||
shouldSkip: shouldSkipMock
|
||||
shouldSkip: shouldSkipMock,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {ActionSkipper, ReleaseActionSkipper} from "../src/ActionSkipper";
|
||||
import {Releases} from "../src/Releases";
|
||||
import { ReleaseActionSkipper } from "../src/ActionSkipper"
|
||||
import type { Releases } from "../src/Releases"
|
||||
|
||||
describe("shouldSkip", () => {
|
||||
const getMock = jest.fn()
|
||||
@@ -12,33 +12,34 @@ describe("shouldSkip", () => {
|
||||
listArtifactsForRelease: jest.fn(),
|
||||
listReleases: jest.fn(),
|
||||
update: jest.fn(),
|
||||
uploadArtifact: jest.fn()
|
||||
uploadArtifact: jest.fn(),
|
||||
generateReleaseNotes: jest.fn(),
|
||||
}
|
||||
})
|
||||
|
||||
it('should return false when skipIfReleaseExists is false', async () => {
|
||||
it("should return false when skipIfReleaseExists is false", async () => {
|
||||
const actionSkipper = new ReleaseActionSkipper(false, MockReleases(), tag)
|
||||
expect(await actionSkipper.shouldSkip()).toBe(false)
|
||||
})
|
||||
|
||||
it('should return false when error occurs', async () => {
|
||||
it("should return false when error occurs", async () => {
|
||||
getMock.mockRejectedValue(new Error())
|
||||
|
||||
const actionSkipper = new ReleaseActionSkipper(true, MockReleases(), tag)
|
||||
expect(await actionSkipper.shouldSkip()).toBe(false)
|
||||
})
|
||||
|
||||
it('should return false when release does not exist', async () => {
|
||||
it("should return false when release does not exist", async () => {
|
||||
getMock.mockResolvedValue({})
|
||||
|
||||
|
||||
const actionSkipper = new ReleaseActionSkipper(true, MockReleases(), tag)
|
||||
expect(await actionSkipper.shouldSkip()).toBe(false)
|
||||
})
|
||||
|
||||
it('should return true when release does exist', async () => {
|
||||
getMock.mockResolvedValue({data: {}})
|
||||
it("should return true when release does exist", async () => {
|
||||
getMock.mockResolvedValue({ data: {} })
|
||||
|
||||
const actionSkipper = new ReleaseActionSkipper(true, MockReleases(), tag)
|
||||
expect(await actionSkipper.shouldSkip()).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
import {Artifact} from "../src/Artifact";
|
||||
import { Artifact } from "../src/Artifact"
|
||||
|
||||
const contentLength = 42
|
||||
const fakeReadStream = {}
|
||||
|
||||
jest.mock('fs', () => {
|
||||
jest.mock("fs", () => {
|
||||
return {
|
||||
createReadStream: () => fakeReadStream,
|
||||
statSync: () => {
|
||||
return {size: contentLength}
|
||||
}
|
||||
};
|
||||
return { size: contentLength }
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe("Artifact", () => {
|
||||
it('defaults contentType to raw', () => {
|
||||
const artifact = new Artifact('')
|
||||
expect(artifact.contentType).toBe('raw')
|
||||
it("defaults contentType to raw", () => {
|
||||
const artifact = new Artifact("")
|
||||
expect(artifact.contentType).toBe("raw")
|
||||
})
|
||||
|
||||
it('generates name from path', () => {
|
||||
const artifact = new Artifact('some/artifact')
|
||||
expect(artifact.name).toBe('artifact')
|
||||
it("generates name from path", () => {
|
||||
const artifact = new Artifact("some/artifact")
|
||||
expect(artifact.name).toBe("artifact")
|
||||
})
|
||||
|
||||
it('provides contentLength', () => {
|
||||
const artifact = new Artifact('some/artifact')
|
||||
it("provides contentLength", () => {
|
||||
const artifact = new Artifact("some/artifact")
|
||||
expect(artifact.contentLength).toBe(contentLength)
|
||||
})
|
||||
|
||||
it('provides path', () => {
|
||||
const artifact = new Artifact('some/artifact')
|
||||
expect(artifact.path).toBe('some/artifact')
|
||||
it("provides path", () => {
|
||||
const artifact = new Artifact("some/artifact")
|
||||
expect(artifact.path).toBe("some/artifact")
|
||||
})
|
||||
|
||||
it('reads artifact', () => {
|
||||
const artifact = new Artifact('some/artifact')
|
||||
it("reads artifact", () => {
|
||||
const artifact = new Artifact("some/artifact")
|
||||
expect(artifact.readFile()).toBe(fakeReadStream)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,45 +1,41 @@
|
||||
import {Artifact} from "../src/Artifact"
|
||||
import {GithubArtifactUploader} from "../src/ArtifactUploader"
|
||||
import {Releases} from "../src/Releases";
|
||||
import {RequestError} from '@octokit/request-error'
|
||||
import {GithubArtifactDestroyer} from "../src/ArtifactDestroyer";
|
||||
import { GithubArtifactDestroyer } from "../src/ArtifactDestroyer"
|
||||
import type { Releases } from "../src/Releases"
|
||||
|
||||
const releaseId = 100
|
||||
|
||||
const deleteMock = jest.fn()
|
||||
const listArtifactsMock = jest.fn()
|
||||
|
||||
|
||||
describe('ArtifactDestroyer', () => {
|
||||
describe("ArtifactDestroyer", () => {
|
||||
beforeEach(() => {
|
||||
deleteMock.mockClear()
|
||||
listArtifactsMock.mockClear()
|
||||
})
|
||||
|
||||
it('destroys all artifacts', async () => {
|
||||
it("destroys all artifacts", async () => {
|
||||
mockListWithAssets()
|
||||
mockDeleteSuccess()
|
||||
const destroyer = createDestroyer()
|
||||
|
||||
await destroyer.destroyArtifacts(releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(2)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('destroys nothing when no artifacts found', async () => {
|
||||
it("destroys nothing when no artifacts found", async () => {
|
||||
mockListWithoutAssets()
|
||||
const destroyer = createDestroyer()
|
||||
|
||||
await destroyer.destroyArtifacts(releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(0)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('throws when delete call fails', async () => {
|
||||
it("throws when delete call fails", async () => {
|
||||
mockListWithAssets()
|
||||
mockDeleteError()
|
||||
const destroyer = createDestroyer()
|
||||
|
||||
|
||||
expect.hasAssertions()
|
||||
try {
|
||||
await destroyer.destroyArtifacts(releaseId)
|
||||
@@ -57,7 +53,8 @@ describe('ArtifactDestroyer', () => {
|
||||
listArtifactsForRelease: listArtifactsMock,
|
||||
listReleases: jest.fn(),
|
||||
update: jest.fn(),
|
||||
uploadArtifact: jest.fn()
|
||||
uploadArtifact: jest.fn(),
|
||||
generateReleaseNotes: jest.fn(),
|
||||
}
|
||||
})
|
||||
return new GithubArtifactDestroyer(new MockReleases())
|
||||
@@ -75,16 +72,16 @@ describe('ArtifactDestroyer', () => {
|
||||
listArtifactsMock.mockResolvedValue([
|
||||
{
|
||||
name: "art1",
|
||||
id: 1
|
||||
id: 1,
|
||||
},
|
||||
{
|
||||
name: "art2",
|
||||
id: 2
|
||||
}
|
||||
id: 2,
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
function mockListWithoutAssets() {
|
||||
listArtifactsMock.mockResolvedValue([])
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
const warnMock = jest.fn()
|
||||
|
||||
import {FileArtifactGlobber} from "../src/ArtifactGlobber"
|
||||
import {Globber} from "../src/Globber";
|
||||
import {Artifact} from "../src/Artifact";
|
||||
import untildify = require("untildify");
|
||||
import { FileArtifactGlobber } from "../src/ArtifactGlobber"
|
||||
import { Globber } from "../src/Globber"
|
||||
import { Artifact } from "../src/Artifact"
|
||||
import untildify = require("untildify")
|
||||
|
||||
const contentType = "raw"
|
||||
const globMock = jest.fn()
|
||||
const globResults = ["file1", "file2"]
|
||||
|
||||
jest.mock('@actions/core', () => {
|
||||
return {warning: warnMock};
|
||||
jest.mock("@actions/core", () => {
|
||||
return { warning: warnMock }
|
||||
})
|
||||
|
||||
jest.mock('fs', () => {
|
||||
jest.mock("fs", () => {
|
||||
return {
|
||||
statSync: () => {
|
||||
return {
|
||||
isDirectory(): boolean {
|
||||
return false
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
realpathSync: () => {
|
||||
return false
|
||||
}
|
||||
};
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe("ArtifactGlobber", () => {
|
||||
@@ -36,79 +36,66 @@ describe("ArtifactGlobber", () => {
|
||||
it("expands paths in which start with a ~", () => {
|
||||
const globber = createArtifactGlobber()
|
||||
|
||||
const expectedArtifacts =
|
||||
globResults.map((path) => new Artifact(path, contentType))
|
||||
const expectedArtifacts = globResults.map((path) => new Artifact(path, contentType))
|
||||
|
||||
expect(globber.globArtifactString('~/path', 'raw', false))
|
||||
.toEqual(expectedArtifacts)
|
||||
expect(globMock).toBeCalledWith(untildify('~/path'))
|
||||
expect(warnMock).not.toBeCalled()
|
||||
expect(globber.globArtifactString("~/path", "raw", false)).toEqual(expectedArtifacts)
|
||||
expect(globMock).toHaveBeenCalledWith(untildify("~/path"))
|
||||
expect(warnMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("globs simple path", () => {
|
||||
const globber = createArtifactGlobber()
|
||||
|
||||
const expectedArtifacts =
|
||||
globResults.map((path) => new Artifact(path, contentType))
|
||||
const expectedArtifacts = globResults.map((path) => new Artifact(path, contentType))
|
||||
|
||||
expect(globber.globArtifactString('path', 'raw', false))
|
||||
.toEqual(expectedArtifacts)
|
||||
expect(globMock).toBeCalledWith('path')
|
||||
expect(warnMock).not.toBeCalled()
|
||||
expect(globber.globArtifactString("path", "raw", false)).toEqual(expectedArtifacts)
|
||||
expect(globMock).toHaveBeenCalledWith("path")
|
||||
expect(warnMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("splits multiple paths with comma separator", () => {
|
||||
const globber = createArtifactGlobber()
|
||||
|
||||
const expectedArtifacts =
|
||||
globResults
|
||||
.concat(globResults)
|
||||
.map((path) => new Artifact(path, contentType))
|
||||
const expectedArtifacts = globResults.concat(globResults).map((path) => new Artifact(path, contentType))
|
||||
|
||||
expect(globber.globArtifactString('path1,path2', 'raw', false))
|
||||
.toEqual(expectedArtifacts)
|
||||
expect(globMock).toBeCalledWith('path1')
|
||||
expect(globMock).toBeCalledWith('path2')
|
||||
expect(warnMock).not.toBeCalled()
|
||||
expect(globber.globArtifactString("path1,path2", "raw", false)).toEqual(expectedArtifacts)
|
||||
expect(globMock).toHaveBeenCalledWith("path1")
|
||||
expect(globMock).toHaveBeenCalledWith("path2")
|
||||
expect(warnMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("splits multiple paths with new line separator and trims start", () => {
|
||||
const globber = createArtifactGlobber()
|
||||
|
||||
const expectedArtifacts =
|
||||
globResults
|
||||
.concat(globResults)
|
||||
.map((path) => new Artifact(path, contentType))
|
||||
const expectedArtifacts = globResults.concat(globResults).map((path) => new Artifact(path, contentType))
|
||||
|
||||
expect(globber.globArtifactString('path1\n path2', 'raw', false))
|
||||
.toEqual(expectedArtifacts)
|
||||
expect(globMock).toBeCalledWith('path1')
|
||||
expect(globMock).toBeCalledWith('path2')
|
||||
expect(warnMock).not.toBeCalled()
|
||||
expect(globber.globArtifactString("path1\n path2", "raw", false)).toEqual(expectedArtifacts)
|
||||
expect(globMock).toHaveBeenCalledWith("path1")
|
||||
expect(globMock).toHaveBeenCalledWith("path2")
|
||||
expect(warnMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("warns when no glob results are produced and empty results shouldn't throw", () => {
|
||||
const globber = createArtifactGlobber([])
|
||||
|
||||
expect(globber.globArtifactString('path', 'raw', false))
|
||||
.toEqual([])
|
||||
expect(warnMock).toBeCalled()
|
||||
expect(globber.globArtifactString("path", "raw", false)).toEqual([])
|
||||
expect(warnMock).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("throws when no glob results are produced and empty results shouild throw", () => {
|
||||
const globber = createArtifactGlobber([])
|
||||
expect(() => {
|
||||
globber.globArtifactString('path', 'raw', true)
|
||||
globber.globArtifactString("path", "raw", true)
|
||||
}).toThrow()
|
||||
})
|
||||
|
||||
function createArtifactGlobber(results: string[] = globResults): FileArtifactGlobber {
|
||||
const MockGlobber = jest.fn<Globber, any>(() => {
|
||||
return {
|
||||
glob: globMock
|
||||
glob: globMock,
|
||||
}
|
||||
})
|
||||
globMock.mockReturnValue(results)
|
||||
return new FileArtifactGlobber(new MockGlobber())
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
const directoryMock = jest.fn()
|
||||
const warnMock = jest.fn()
|
||||
|
||||
import {ArtifactPathValidator} from "../src/ArtifactPathValidator";
|
||||
import { ArtifactPathValidator } from "../src/ArtifactPathValidator"
|
||||
|
||||
const pattern = 'pattern'
|
||||
const pattern = "pattern"
|
||||
|
||||
jest.mock('@actions/core', () => {
|
||||
return {warning: warnMock};
|
||||
jest.mock("@actions/core", () => {
|
||||
return { warning: warnMock }
|
||||
})
|
||||
|
||||
jest.mock('fs', () => {
|
||||
jest.mock("fs", () => {
|
||||
return {
|
||||
statSync: () => {
|
||||
return {isDirectory: directoryMock}
|
||||
}
|
||||
};
|
||||
return { isDirectory: directoryMock }
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe("ArtifactPathValidator", () => {
|
||||
@@ -24,20 +24,20 @@ describe("ArtifactPathValidator", () => {
|
||||
})
|
||||
|
||||
it("warns and filters out path which points to a directory", () => {
|
||||
const paths = ['path1', 'path2']
|
||||
const paths = ["path1", "path2"]
|
||||
directoryMock.mockReturnValueOnce(true).mockReturnValueOnce(false)
|
||||
|
||||
const validator = new ArtifactPathValidator(false, paths, pattern)
|
||||
|
||||
const result = validator.validate()
|
||||
expect(warnMock).toBeCalled()
|
||||
expect(result).toEqual(['path2'])
|
||||
expect(warnMock).toHaveBeenCalled()
|
||||
expect(result).toEqual(["path2"])
|
||||
})
|
||||
|
||||
it("warns when no glob results are produced and empty results shouldn't throw", () => {
|
||||
const validator = new ArtifactPathValidator(false, [], pattern)
|
||||
const result = validator.validate()
|
||||
expect(warnMock).toBeCalled()
|
||||
expect(warnMock).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("throws when no glob results are produced and empty results shouild throw", () => {
|
||||
@@ -48,7 +48,7 @@ describe("ArtifactPathValidator", () => {
|
||||
})
|
||||
|
||||
it("throws when path points to directory", () => {
|
||||
const paths = ['path1', 'path2']
|
||||
const paths = ["path1", "path2"]
|
||||
directoryMock.mockReturnValueOnce(true).mockReturnValueOnce(false)
|
||||
|
||||
const validator = new ArtifactPathValidator(true, paths, pattern)
|
||||
@@ -57,4 +57,4 @@ describe("ArtifactPathValidator", () => {
|
||||
validator.validate()
|
||||
}).toThrow()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,79 +1,69 @@
|
||||
import {Artifact} from "../src/Artifact"
|
||||
import {GithubArtifactUploader} from "../src/ArtifactUploader"
|
||||
import {Releases} from "../src/Releases";
|
||||
import {RequestError} from '@octokit/request-error'
|
||||
import { RequestError } from "@octokit/request-error"
|
||||
import { Artifact } from "../src/Artifact"
|
||||
import { GithubArtifactUploader } from "../src/ArtifactUploader"
|
||||
import type { Releases } from "../src/Releases"
|
||||
|
||||
const artifacts = [
|
||||
new Artifact('a/art1'),
|
||||
new Artifact('b/art2')
|
||||
]
|
||||
const artifacts = [new Artifact("a/art1"), new Artifact("b/art2")]
|
||||
const fakeReadStream = {}
|
||||
const contentLength = 42
|
||||
const releaseId = 100
|
||||
const url = 'http://api.example.com'
|
||||
const url = "http://api.example.com"
|
||||
|
||||
const deleteMock = jest.fn()
|
||||
const listArtifactsMock = jest.fn()
|
||||
const uploadMock = jest.fn()
|
||||
|
||||
jest.mock('fs', () => {
|
||||
const originalFs = jest.requireActual('fs');
|
||||
jest.mock("fs", () => {
|
||||
const originalFs = jest.requireActual("fs")
|
||||
return {
|
||||
...originalFs,
|
||||
promises: {},
|
||||
createReadStream: () => fakeReadStream,
|
||||
statSync: () => {
|
||||
return {size: contentLength};
|
||||
}
|
||||
};
|
||||
});
|
||||
return { size: contentLength }
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe('ArtifactUploader', () => {
|
||||
describe("ArtifactUploader", () => {
|
||||
beforeEach(() => {
|
||||
deleteMock.mockClear()
|
||||
listArtifactsMock.mockClear()
|
||||
uploadMock.mockClear()
|
||||
})
|
||||
|
||||
it('abort when upload failed with non-5xx response', async () => {
|
||||
it("abort when upload failed with non-5xx response", async () => {
|
||||
mockListWithoutAssets()
|
||||
mockUploadArtifact(401, 2)
|
||||
const uploader = createUploader(true)
|
||||
|
||||
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||
|
||||
expect(uploadMock).toBeCalledTimes(2)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledTimes(2)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(0)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('abort when upload failed with 5xx response after 3 attempts', async () => {
|
||||
it("abort when upload failed with 5xx response after 3 attempts", async () => {
|
||||
mockListWithoutAssets()
|
||||
mockUploadArtifact(500, 4)
|
||||
const uploader = createUploader(true)
|
||||
|
||||
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||
|
||||
expect(uploadMock).toBeCalledTimes(5)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledTimes(5)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(0)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('replaces all artifacts', async () => {
|
||||
it("replaces all artifacts", async () => {
|
||||
mockDeleteSuccess()
|
||||
mockListWithAssets()
|
||||
mockUploadArtifact()
|
||||
@@ -81,18 +71,16 @@ describe('ArtifactUploader', () => {
|
||||
|
||||
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||
|
||||
expect(uploadMock).toBeCalledTimes(2)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledTimes(2)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(2)
|
||||
expect(deleteMock).toBeCalledWith(1)
|
||||
expect(deleteMock).toBeCalledWith(2)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(2)
|
||||
expect(deleteMock).toHaveBeenCalledWith(1)
|
||||
expect(deleteMock).toHaveBeenCalledWith(2)
|
||||
})
|
||||
|
||||
it('replaces no artifacts when previous asset list empty', async () => {
|
||||
it("replaces no artifacts when previous asset list empty", async () => {
|
||||
mockDeleteSuccess()
|
||||
mockListWithoutAssets()
|
||||
mockUploadArtifact()
|
||||
@@ -100,36 +88,30 @@ describe('ArtifactUploader', () => {
|
||||
|
||||
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||
|
||||
expect(uploadMock).toBeCalledTimes(2)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledTimes(2)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(0)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('retry when upload failed with 5xx response', async () => {
|
||||
it("retry when upload failed with 5xx response", async () => {
|
||||
mockListWithoutAssets()
|
||||
mockUploadArtifact(500, 2)
|
||||
const uploader = createUploader(true)
|
||||
|
||||
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||
|
||||
expect(uploadMock).toBeCalledTimes(4)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledTimes(4)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(0)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('throws upload error when replacesExistingArtifacts is true', async () => {
|
||||
it("throws upload error when replacesExistingArtifacts is true", async () => {
|
||||
mockListWithoutAssets()
|
||||
mockUploadError()
|
||||
const uploader = createUploader(true, true)
|
||||
@@ -142,7 +124,7 @@ describe('ArtifactUploader', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('throws error from replace', async () => {
|
||||
it("throws error from replace", async () => {
|
||||
mockDeleteError()
|
||||
mockListWithAssets()
|
||||
mockUploadArtifact()
|
||||
@@ -156,7 +138,7 @@ describe('ArtifactUploader', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('updates all artifacts, delete none', async () => {
|
||||
it("updates all artifacts, delete none", async () => {
|
||||
mockDeleteError()
|
||||
mockListWithAssets()
|
||||
mockUploadArtifact()
|
||||
@@ -164,16 +146,14 @@ describe('ArtifactUploader', () => {
|
||||
|
||||
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||
|
||||
expect(uploadMock).toBeCalledTimes(2)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art1', releaseId)
|
||||
expect(uploadMock)
|
||||
.toBeCalledWith(url, contentLength, 'raw', fakeReadStream, 'art2', releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledTimes(2)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art1", releaseId)
|
||||
expect(uploadMock).toHaveBeenCalledWith(url, contentLength, "raw", fakeReadStream, "art2", releaseId)
|
||||
|
||||
expect(deleteMock).toBeCalledTimes(0)
|
||||
expect(deleteMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
function createUploader(replaces: boolean, throws: boolean = false): GithubArtifactUploader {
|
||||
function createUploader(replaces: boolean, throws = false): GithubArtifactUploader {
|
||||
const MockReleases = jest.fn<Releases, any>(() => {
|
||||
return {
|
||||
create: jest.fn(),
|
||||
@@ -182,7 +162,8 @@ describe('ArtifactUploader', () => {
|
||||
listArtifactsForRelease: listArtifactsMock,
|
||||
listReleases: jest.fn(),
|
||||
update: jest.fn(),
|
||||
uploadArtifact: uploadMock
|
||||
uploadArtifact: uploadMock,
|
||||
generateReleaseNotes: jest.fn(),
|
||||
}
|
||||
})
|
||||
return new GithubArtifactUploader(new MockReleases(), replaces, throws)
|
||||
@@ -200,12 +181,12 @@ describe('ArtifactUploader', () => {
|
||||
listArtifactsMock.mockResolvedValue([
|
||||
{
|
||||
name: "art1",
|
||||
id: 1
|
||||
id: 1,
|
||||
},
|
||||
{
|
||||
name: "art2",
|
||||
id: 2
|
||||
}
|
||||
id: 2,
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
@@ -213,10 +194,10 @@ describe('ArtifactUploader', () => {
|
||||
listArtifactsMock.mockResolvedValue([])
|
||||
}
|
||||
|
||||
function mockUploadArtifact(status: number = 200, failures: number = 0) {
|
||||
function mockUploadArtifact(status = 200, failures = 0) {
|
||||
const error = new RequestError(`HTTP ${status}`, status, {
|
||||
headers: {},
|
||||
request: {method: 'GET', url: '', headers: {}}
|
||||
request: { method: "GET", url: "", headers: {} },
|
||||
})
|
||||
for (let index = 0; index < failures; index++) {
|
||||
uploadMock.mockRejectedValueOnce(error)
|
||||
@@ -227,7 +208,7 @@ describe('ArtifactUploader', () => {
|
||||
function mockUploadError() {
|
||||
uploadMock.mockRejectedValue({
|
||||
message: "error",
|
||||
status: 502
|
||||
status: 502,
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -1,93 +1,95 @@
|
||||
import { GithubError } from "../src/GithubError"
|
||||
|
||||
describe('ErrorMessage', () => {
|
||||
|
||||
describe('has error with code', () => {
|
||||
describe("ErrorMessage", () => {
|
||||
describe("has error with code", () => {
|
||||
const error = {
|
||||
message: 'something bad happened',
|
||||
message: "something bad happened",
|
||||
errors: [
|
||||
{
|
||||
code: 'missing',
|
||||
resource: 'release'
|
||||
code: "missing",
|
||||
resource: "release",
|
||||
},
|
||||
{
|
||||
code: 'already_exists',
|
||||
resource: 'release'
|
||||
}
|
||||
code: "already_exists",
|
||||
resource: "release",
|
||||
},
|
||||
],
|
||||
status: 422
|
||||
status: 422,
|
||||
}
|
||||
|
||||
it('does not have error', () => {
|
||||
it("does not have error", () => {
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.hasErrorWithCode('missing_field')).toBeFalsy()
|
||||
expect(githubError.hasErrorWithCode("missing_field")).toBeFalsy()
|
||||
})
|
||||
|
||||
it('has error', () => {
|
||||
it("has error", () => {
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.hasErrorWithCode('missing')).toBeTruthy()
|
||||
expect(githubError.hasErrorWithCode("missing")).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('has error with remediation', () => {
|
||||
it('provides remediation with 404 without errors', () => {
|
||||
describe("has error with remediation", () => {
|
||||
it("provides remediation with 404 without errors", () => {
|
||||
const error = { status: 404, message: "message" }
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.toString())
|
||||
.toBe('Error 404: message\nMake sure your github token has access to the repo and has permission to author releases')
|
||||
expect(githubError.toString()).toBe(
|
||||
"Error 404: message\nMake sure your github token has access to the repo and has permission to author releases"
|
||||
)
|
||||
})
|
||||
|
||||
it('provides remediation with 404 with errors', () => {
|
||||
it("provides remediation with 404 with errors", () => {
|
||||
const error = {
|
||||
message: 'message',
|
||||
message: "message",
|
||||
errors: [
|
||||
{
|
||||
code: 'missing',
|
||||
resource: 'release'
|
||||
}
|
||||
code: "missing",
|
||||
resource: "release",
|
||||
},
|
||||
],
|
||||
status: 404
|
||||
status: 404,
|
||||
}
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.toString())
|
||||
.toBe('Error 404: message\nErrors:\n- release does not exist.\nMake sure your github token has access to the repo and has permission to author releases')
|
||||
expect(githubError.toString()).toBe(
|
||||
"Error 404: message\nErrors:\n- release does not exist.\nMake sure your github token has access to the repo and has permission to author releases"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('generates message with errors', () => {
|
||||
|
||||
it("generates message with errors", () => {
|
||||
const error = {
|
||||
message: 'something bad happened',
|
||||
message: "something bad happened",
|
||||
errors: [
|
||||
{
|
||||
code: 'missing',
|
||||
resource: 'release'
|
||||
code: "missing",
|
||||
resource: "release",
|
||||
},
|
||||
{
|
||||
code: 'already_exists',
|
||||
resource: 'release'
|
||||
}
|
||||
code: "already_exists",
|
||||
resource: "release",
|
||||
},
|
||||
],
|
||||
status: 422
|
||||
status: 422,
|
||||
}
|
||||
|
||||
const githubError = new GithubError(error)
|
||||
|
||||
const expectedString = "Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists."
|
||||
const expectedString =
|
||||
"Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists."
|
||||
expect(githubError.toString()).toBe(expectedString)
|
||||
})
|
||||
|
||||
it('generates message without errors', () => {
|
||||
it("generates message without errors", () => {
|
||||
const error = {
|
||||
message: 'something bad happened',
|
||||
status: 422
|
||||
message: "something bad happened",
|
||||
status: 422,
|
||||
}
|
||||
|
||||
const githubError = new GithubError(error)
|
||||
|
||||
expect(githubError.toString()).toBe('Error 422: something bad happened')
|
||||
expect(githubError.toString()).toBe("Error 422: something bad happened")
|
||||
})
|
||||
|
||||
it('provides error status', () => {
|
||||
it("provides error status", () => {
|
||||
const error = { status: 404 }
|
||||
const githubError = new GithubError(error)
|
||||
expect(githubError.status).toBe(404)
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import { GithubErrorDetail } from "../src/GithubErrorDetail"
|
||||
|
||||
describe('GithubErrorDetail', () => {
|
||||
|
||||
it('provides error code', () => {
|
||||
describe("GithubErrorDetail", () => {
|
||||
it("provides error code", () => {
|
||||
const error = {
|
||||
code: "missing"
|
||||
code: "missing",
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
|
||||
expect(detail.code).toBe('missing')
|
||||
expect(detail.code).toBe("missing")
|
||||
})
|
||||
|
||||
it('generates missing resource error message', () => {
|
||||
it("generates missing resource error message", () => {
|
||||
const resource = "release"
|
||||
const error = {
|
||||
code: "missing",
|
||||
resource: resource
|
||||
resource: resource,
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
@@ -25,13 +24,13 @@ describe('GithubErrorDetail', () => {
|
||||
expect(message).toBe(`${resource} does not exist.`)
|
||||
})
|
||||
|
||||
it('generates missing field error message', () => {
|
||||
it("generates missing field error message", () => {
|
||||
const resource = "release"
|
||||
const field = "body"
|
||||
const error = {
|
||||
code: "missing_field",
|
||||
field: field,
|
||||
resource: resource
|
||||
resource: resource,
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
@@ -40,13 +39,13 @@ describe('GithubErrorDetail', () => {
|
||||
expect(message).toBe(`The ${field} field on ${resource} is missing.`)
|
||||
})
|
||||
|
||||
it('generates invalid field error message', () => {
|
||||
it("generates invalid field error message", () => {
|
||||
const resource = "release"
|
||||
const field = "body"
|
||||
const error = {
|
||||
code: "invalid",
|
||||
field: field,
|
||||
resource: resource
|
||||
resource: resource,
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
@@ -55,11 +54,11 @@ describe('GithubErrorDetail', () => {
|
||||
expect(message).toBe(`The ${field} field on ${resource} is an invalid format.`)
|
||||
})
|
||||
|
||||
it('generates resource already exists error message', () => {
|
||||
it("generates resource already exists error message", () => {
|
||||
const resource = "release"
|
||||
const error = {
|
||||
code: "already_exists",
|
||||
resource: resource
|
||||
resource: resource,
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
@@ -68,13 +67,13 @@ describe('GithubErrorDetail', () => {
|
||||
expect(message).toBe(`${resource} already exists.`)
|
||||
})
|
||||
|
||||
describe('generates custom error message', () => {
|
||||
it('with documentation url', () => {
|
||||
describe("generates custom error message", () => {
|
||||
it("with documentation url", () => {
|
||||
const url = "https://api.example.com"
|
||||
const error = {
|
||||
code: "custom",
|
||||
message: "foo",
|
||||
documentation_url: url
|
||||
documentation_url: url,
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
@@ -83,16 +82,16 @@ describe('GithubErrorDetail', () => {
|
||||
expect(message).toBe(`foo\nPlease see ${url}.`)
|
||||
})
|
||||
|
||||
it('without documentation url', () => {
|
||||
it("without documentation url", () => {
|
||||
const error = {
|
||||
code: "custom",
|
||||
message: "foo"
|
||||
message: "foo",
|
||||
}
|
||||
|
||||
const detail = new GithubErrorDetail(error)
|
||||
const message = detail.toString()
|
||||
|
||||
expect(message).toBe('foo')
|
||||
expect(message).toBe("foo")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
const mockGetInput = jest.fn();
|
||||
const mockGetBooleanInput = jest.fn();
|
||||
const mockGetInput = jest.fn()
|
||||
const mockGetBooleanInput = jest.fn()
|
||||
const mockGlob = jest.fn()
|
||||
const mockReadFileSync = jest.fn();
|
||||
const mockStatSync = jest.fn();
|
||||
const mockReadFileSync = jest.fn()
|
||||
const mockStatSync = jest.fn()
|
||||
|
||||
import {Artifact} from "../src/Artifact";
|
||||
import {ArtifactGlobber} from "../src/ArtifactGlobber";
|
||||
import {Context} from "@actions/github/lib/context";
|
||||
import {Inputs, CoreInputs} from "../src/Inputs";
|
||||
import { Artifact } from "../src/Artifact"
|
||||
import { ArtifactGlobber } from "../src/ArtifactGlobber"
|
||||
import { Context } from "@actions/github/lib/context"
|
||||
import { Inputs, CoreInputs } from "../src/Inputs"
|
||||
|
||||
const artifacts = [
|
||||
new Artifact('a/art1'),
|
||||
new Artifact('b/art2')
|
||||
]
|
||||
const artifacts = [new Artifact("a/art1"), new Artifact("b/art2")]
|
||||
|
||||
jest.mock('@actions/core', () => {
|
||||
jest.mock("@actions/core", () => {
|
||||
return {
|
||||
getInput: mockGetInput,
|
||||
getBooleanInput: mockGetBooleanInput
|
||||
};
|
||||
getBooleanInput: mockGetBooleanInput,
|
||||
}
|
||||
})
|
||||
|
||||
jest.mock('fs', () => {
|
||||
jest.mock("fs", () => {
|
||||
// existsSync is used by Context's constructor
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
return {
|
||||
@@ -29,460 +26,416 @@ jest.mock('fs', () => {
|
||||
return false
|
||||
},
|
||||
readFileSync: mockReadFileSync,
|
||||
statSync: mockStatSync
|
||||
};
|
||||
statSync: mockStatSync,
|
||||
}
|
||||
})
|
||||
|
||||
describe('Inputs', () => {
|
||||
let context: Context;
|
||||
let inputs: Inputs;
|
||||
describe("Inputs", () => {
|
||||
let context: Context
|
||||
let inputs: Inputs
|
||||
beforeEach(() => {
|
||||
mockGetInput.mockReset()
|
||||
context = new Context()
|
||||
inputs = new CoreInputs(createGlobber(), context)
|
||||
})
|
||||
|
||||
describe('commit', () => {
|
||||
it('returns commit', () => {
|
||||
mockGetInput.mockReturnValueOnce('commit')
|
||||
expect(inputs.commit).toBe('commit')
|
||||
describe("commit", () => {
|
||||
it("returns commit", () => {
|
||||
mockGetInput.mockReturnValueOnce("commit")
|
||||
expect(inputs.commit).toBe("commit")
|
||||
})
|
||||
|
||||
it('returns undefined when omitted', () => {
|
||||
mockGetInput.mockReturnValueOnce('')
|
||||
it("returns undefined when omitted", () => {
|
||||
mockGetInput.mockReturnValueOnce("")
|
||||
expect(inputs.commit).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
it('returns token', () => {
|
||||
mockGetInput.mockReturnValue('42')
|
||||
expect(inputs.token).toBe('42')
|
||||
it("returns token", () => {
|
||||
mockGetInput.mockReturnValue("42")
|
||||
expect(inputs.token).toBe("42")
|
||||
})
|
||||
|
||||
describe('allowsUpdates', () => {
|
||||
it('returns false', () => {
|
||||
describe("allowsUpdates", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.allowUpdates).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.allowUpdates).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('artifactErrorsFailBuild', () => {
|
||||
it('returns false', () => {
|
||||
describe("artifactErrorsFailBuild", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.artifactErrorsFailBuild).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.artifactErrorsFailBuild).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('artifacts', () => {
|
||||
it('globber told to throw errors', () => {
|
||||
mockGetInput.mockReturnValueOnce('art1')
|
||||
.mockReturnValueOnce('contentType')
|
||||
.mockReturnValueOnce('true')
|
||||
describe("artifacts", () => {
|
||||
it("globber told to throw errors", () => {
|
||||
mockGetInput.mockReturnValueOnce("art1").mockReturnValueOnce("contentType").mockReturnValueOnce("true")
|
||||
|
||||
expect(inputs.artifacts).toEqual(artifacts)
|
||||
expect(mockGlob).toBeCalledTimes(1)
|
||||
expect(mockGlob).toBeCalledWith('art1', 'contentType', true)
|
||||
expect(mockGlob).toHaveBeenCalledTimes(1)
|
||||
expect(mockGlob).toHaveBeenCalledWith("art1", "contentType", true)
|
||||
})
|
||||
|
||||
it('returns empty artifacts', () => {
|
||||
mockGetInput.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('')
|
||||
it("returns empty artifacts", () => {
|
||||
mockGetInput.mockReturnValueOnce("").mockReturnValueOnce("")
|
||||
|
||||
expect(inputs.artifacts).toEqual([])
|
||||
expect(mockGlob).toBeCalledTimes(0)
|
||||
expect(mockGlob).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('returns input.artifacts', () => {
|
||||
mockGetInput.mockReturnValueOnce('art1')
|
||||
.mockReturnValueOnce('contentType')
|
||||
.mockReturnValueOnce('false')
|
||||
it("returns input.artifacts", () => {
|
||||
mockGetInput.mockReturnValueOnce("art1").mockReturnValueOnce("contentType").mockReturnValueOnce("false")
|
||||
|
||||
expect(inputs.artifacts).toEqual(artifacts)
|
||||
expect(mockGlob).toBeCalledTimes(1)
|
||||
expect(mockGlob).toBeCalledWith('art1', 'contentType', false)
|
||||
expect(mockGlob).toHaveBeenCalledTimes(1)
|
||||
expect(mockGlob).toHaveBeenCalledWith("art1", "contentType", false)
|
||||
})
|
||||
|
||||
it('returns input.artifacts with default contentType', () => {
|
||||
mockGetInput.mockReturnValueOnce('art1')
|
||||
.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('false')
|
||||
it("returns input.artifacts with default contentType", () => {
|
||||
mockGetInput.mockReturnValueOnce("art1").mockReturnValueOnce("").mockReturnValueOnce("false")
|
||||
|
||||
expect(inputs.artifacts).toEqual(artifacts)
|
||||
expect(mockGlob).toBeCalledTimes(1)
|
||||
expect(mockGlob).toBeCalledWith('art1', 'raw', false)
|
||||
expect(mockGlob).toHaveBeenCalledTimes(1)
|
||||
expect(mockGlob).toHaveBeenCalledWith("art1", "raw", false)
|
||||
})
|
||||
|
||||
it('returns input.artifact', () => {
|
||||
mockGetInput.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('art2')
|
||||
.mockReturnValueOnce('contentType')
|
||||
.mockReturnValueOnce('false')
|
||||
it("returns input.artifact", () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce("")
|
||||
.mockReturnValueOnce("art2")
|
||||
.mockReturnValueOnce("contentType")
|
||||
.mockReturnValueOnce("false")
|
||||
|
||||
expect(inputs.artifacts).toEqual(artifacts)
|
||||
expect(mockGlob).toBeCalledTimes(1)
|
||||
expect(mockGlob).toBeCalledWith('art2', 'contentType', false)
|
||||
expect(mockGlob).toHaveBeenCalledTimes(1)
|
||||
expect(mockGlob).toHaveBeenCalledWith("art2", "contentType", false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('createdDraft', () => {
|
||||
it('returns false', () => {
|
||||
describe("createdDraft", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.createdDraft).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.createdDraft).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('createdReleaseBody', () => {
|
||||
it('returns input body', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('body')
|
||||
expect(inputs.createdReleaseBody).toBe('body')
|
||||
describe("createdReleaseBody", () => {
|
||||
it("returns input body", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("body")
|
||||
expect(inputs.createdReleaseBody).toBe("body")
|
||||
})
|
||||
|
||||
it('returns body file contents', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('a/path')
|
||||
mockReadFileSync.mockReturnValue('file')
|
||||
it("returns body file contents", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("").mockReturnValueOnce("a/path")
|
||||
mockReadFileSync.mockReturnValue("file")
|
||||
|
||||
expect(inputs.createdReleaseBody).toBe('file')
|
||||
expect(inputs.createdReleaseBody).toBe("file")
|
||||
})
|
||||
|
||||
it('returns empty', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('')
|
||||
expect(inputs.createdReleaseBody).toBe('')
|
||||
it("returns empty", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("").mockReturnValueOnce("")
|
||||
expect(inputs.createdReleaseBody).toBe("")
|
||||
})
|
||||
|
||||
it('returns undefined when omitted', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('body')
|
||||
it("returns undefined when omitted", () => {
|
||||
mockGetInput.mockReturnValueOnce("true").mockReturnValueOnce("body")
|
||||
expect(inputs.createdReleaseBody).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('createdReleaseName', () => {
|
||||
it('returns input name', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('name')
|
||||
expect(inputs.createdReleaseName).toBe('name')
|
||||
describe("createdReleaseName", () => {
|
||||
it("returns input name", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("name")
|
||||
expect(inputs.createdReleaseName).toBe("name")
|
||||
})
|
||||
|
||||
it('returns undefined when omitted', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('name')
|
||||
it("returns undefined when omitted", () => {
|
||||
mockGetInput.mockReturnValueOnce("true").mockReturnValueOnce("name")
|
||||
expect(inputs.createdReleaseName).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns tag', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('')
|
||||
context.ref = 'refs/tags/sha-tag'
|
||||
expect(inputs.createdReleaseName).toBe('sha-tag')
|
||||
it("returns tag", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("")
|
||||
context.ref = "refs/tags/sha-tag"
|
||||
expect(inputs.createdReleaseName).toBe("sha-tag")
|
||||
})
|
||||
})
|
||||
|
||||
describe('discussionCategory', () => {
|
||||
it('returns category', () => {
|
||||
mockGetInput.mockReturnValue('Release')
|
||||
expect(inputs.discussionCategory).toBe('Release')
|
||||
describe("discussionCategory", () => {
|
||||
it("returns category", () => {
|
||||
mockGetInput.mockReturnValue("Release")
|
||||
expect(inputs.discussionCategory).toBe("Release")
|
||||
})
|
||||
|
||||
it('returns undefined', () => {
|
||||
mockGetInput.mockReturnValue('')
|
||||
it("returns undefined", () => {
|
||||
mockGetInput.mockReturnValue("")
|
||||
expect(inputs.discussionCategory).toBe(undefined)
|
||||
})
|
||||
})
|
||||
|
||||
describe('generateReleaseNotes', () => {
|
||||
it('returns returns true', function () {
|
||||
describe("generateReleaseNotes", () => {
|
||||
it("returns returns true", function () {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.generateReleaseNotes).toBe(true)
|
||||
});
|
||||
})
|
||||
|
||||
it('returns false when omitted', function () {
|
||||
it("returns false when omitted", function () {
|
||||
mockGetInput.mockReturnValue("")
|
||||
expect(inputs.generateReleaseNotes).toBe(false)
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
describe('makeLatest', () => {
|
||||
it('returns legacy', () => {
|
||||
mockGetInput.mockReturnValueOnce('legacy')
|
||||
expect(inputs.makeLatest).toBe('legacy')
|
||||
describe("makeLatest", () => {
|
||||
it("returns legacy", () => {
|
||||
mockGetInput.mockReturnValueOnce("legacy")
|
||||
expect(inputs.makeLatest).toBe("legacy")
|
||||
})
|
||||
|
||||
it('returns false', () => {
|
||||
mockGetInput.mockReturnValueOnce('false')
|
||||
expect(inputs.makeLatest).toBe('false')
|
||||
it("returns false", () => {
|
||||
mockGetInput.mockReturnValueOnce("false")
|
||||
expect(inputs.makeLatest).toBe("false")
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValueOnce('true')
|
||||
expect(inputs.makeLatest).toBe('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValueOnce("true")
|
||||
expect(inputs.makeLatest).toBe("true")
|
||||
})
|
||||
|
||||
it('returns undefined', () => {
|
||||
mockGetInput.mockReturnValueOnce('something_else')
|
||||
it("returns undefined", () => {
|
||||
mockGetInput.mockReturnValueOnce("something_else")
|
||||
expect(inputs.makeLatest).toBe(undefined)
|
||||
})
|
||||
})
|
||||
|
||||
describe('owner', () => {
|
||||
it('returns owner from context', function () {
|
||||
describe("owner", () => {
|
||||
it("returns owner from context", function () {
|
||||
process.env.GITHUB_REPOSITORY = "owner/repo"
|
||||
mockGetInput.mockReturnValue("")
|
||||
expect(inputs.owner).toBe("owner")
|
||||
});
|
||||
it('returns owner from inputs', function () {
|
||||
})
|
||||
it("returns owner from inputs", function () {
|
||||
mockGetInput.mockReturnValue("owner")
|
||||
expect(inputs.owner).toBe("owner")
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
describe('createdPrerelase', () => {
|
||||
it('returns false', () => {
|
||||
describe("createdPrerelase", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.createdPrerelease).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.createdPrerelease).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('replacesArtifacts', () => {
|
||||
it('returns false', () => {
|
||||
describe("replacesArtifacts", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.replacesArtifacts).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.replacesArtifacts).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeArtifacts', () => {
|
||||
it('returns false', () => {
|
||||
describe("removeArtifacts", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.removeArtifacts).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValue("true")
|
||||
expect(inputs.removeArtifacts).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('repo', () => {
|
||||
it('returns repo from context', function () {
|
||||
describe("repo", () => {
|
||||
it("returns repo from context", function () {
|
||||
process.env.GITHUB_REPOSITORY = "owner/repo"
|
||||
mockGetInput.mockReturnValue("")
|
||||
expect(inputs.repo).toBe("repo")
|
||||
});
|
||||
it('returns repo from inputs', function () {
|
||||
})
|
||||
it("returns repo from inputs", function () {
|
||||
mockGetInput.mockReturnValue("repo")
|
||||
expect(inputs.repo).toBe("repo")
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
describe('skipIfReleaseExists', () => {
|
||||
it('returns false', () => {
|
||||
describe("skipIfReleaseExists", () => {
|
||||
it("returns false", () => {
|
||||
mockGetBooleanInput.mockReturnValue(false)
|
||||
expect(inputs.skipIfReleaseExists).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
it("returns true", () => {
|
||||
mockGetBooleanInput.mockReturnValue(true)
|
||||
expect(inputs.skipIfReleaseExists).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('tag', () => {
|
||||
it('returns input tag', () => {
|
||||
mockGetInput.mockReturnValue('tag')
|
||||
expect(inputs.tag).toBe('tag')
|
||||
describe("tag", () => {
|
||||
it("returns input tag", () => {
|
||||
mockGetInput.mockReturnValue("tag")
|
||||
expect(inputs.tag).toBe("tag")
|
||||
})
|
||||
it('returns context sha when input is empty', () => {
|
||||
mockGetInput.mockReturnValue('')
|
||||
context.ref = 'refs/tags/sha-tag'
|
||||
expect(inputs.tag).toBe('sha-tag')
|
||||
it("returns context sha when input is empty", () => {
|
||||
mockGetInput.mockReturnValue("")
|
||||
context.ref = "refs/tags/sha-tag"
|
||||
expect(inputs.tag).toBe("sha-tag")
|
||||
})
|
||||
it('returns context sha when input is null', () => {
|
||||
it("returns context sha when input is null", () => {
|
||||
mockGetInput.mockReturnValue(null)
|
||||
context.ref = 'refs/tags/sha-tag'
|
||||
expect(inputs.tag).toBe('sha-tag')
|
||||
context.ref = "refs/tags/sha-tag"
|
||||
expect(inputs.tag).toBe("sha-tag")
|
||||
})
|
||||
it('throws if no tag', () => {
|
||||
it("throws if no tag", () => {
|
||||
context.ref = ""
|
||||
expect(() => inputs.tag).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('updatedDraft', () => {
|
||||
it('returns false', () => {
|
||||
describe("updatedDraft", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.updatedDraft).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValue('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValue("true")
|
||||
expect(inputs.updatedDraft).toBe(true)
|
||||
})
|
||||
|
||||
it('returns true when omitted is blank', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('')
|
||||
.mockReturnValue('true')
|
||||
it("returns true when omitted is blank", () => {
|
||||
mockGetInput.mockReturnValueOnce("").mockReturnValue("true")
|
||||
expect(inputs.updatedDraft).toBe(true)
|
||||
})
|
||||
|
||||
it('returns undefined when omitted for update', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('true')
|
||||
it("returns undefined when omitted for update", () => {
|
||||
mockGetInput.mockReturnValueOnce("true").mockReturnValueOnce("true")
|
||||
expect(inputs.updatedDraft).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('updatedReleaseBody', () => {
|
||||
it('returns input body', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('body')
|
||||
expect(inputs.updatedReleaseBody).toBe('body')
|
||||
describe("updatedReleaseBody", () => {
|
||||
it("returns input body", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("false").mockReturnValueOnce("body")
|
||||
expect(inputs.updatedReleaseBody).toBe("body")
|
||||
})
|
||||
|
||||
it('returns body file contents', () => {
|
||||
it("returns body file contents", () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('a/path')
|
||||
mockReadFileSync.mockReturnValue('file')
|
||||
.mockReturnValueOnce("false")
|
||||
.mockReturnValueOnce("false")
|
||||
.mockReturnValueOnce("")
|
||||
.mockReturnValueOnce("a/path")
|
||||
mockReadFileSync.mockReturnValue("file")
|
||||
|
||||
expect(inputs.updatedReleaseBody).toBe('file')
|
||||
expect(inputs.updatedReleaseBody).toBe("file")
|
||||
})
|
||||
|
||||
it('returns empty', () => {
|
||||
it("returns empty", () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('')
|
||||
.mockReturnValueOnce('')
|
||||
expect(inputs.updatedReleaseBody).toBe('')
|
||||
.mockReturnValueOnce("false")
|
||||
.mockReturnValueOnce("false")
|
||||
.mockReturnValueOnce("")
|
||||
.mockReturnValueOnce("")
|
||||
expect(inputs.updatedReleaseBody).toBe("")
|
||||
})
|
||||
|
||||
it('returns undefined when omitted', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('body')
|
||||
it("returns undefined when omitted", () => {
|
||||
mockGetInput.mockReturnValueOnce("true").mockReturnValueOnce("false").mockReturnValueOnce("body")
|
||||
expect(inputs.updatedReleaseBody).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns undefined when omitted for update', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('body')
|
||||
it("returns undefined when omitted for update", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("true").mockReturnValueOnce("body")
|
||||
expect(inputs.updatedReleaseBody).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('updatedReleaseName', () => {
|
||||
it('returns input name', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('name')
|
||||
expect(inputs.updatedReleaseName).toBe('name')
|
||||
describe("updatedReleaseName", () => {
|
||||
it("returns input name", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("false").mockReturnValueOnce("name")
|
||||
expect(inputs.updatedReleaseName).toBe("name")
|
||||
})
|
||||
|
||||
it('returns undefined when omitted', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('name')
|
||||
it("returns undefined when omitted", () => {
|
||||
mockGetInput.mockReturnValueOnce("true").mockReturnValueOnce("false").mockReturnValueOnce("name")
|
||||
expect(inputs.updatedReleaseName).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns undefined when omitted for update', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('name')
|
||||
it("returns undefined when omitted for update", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("true").mockReturnValueOnce("name")
|
||||
expect(inputs.updatedReleaseName).toBeUndefined()
|
||||
})
|
||||
|
||||
it('returns tag', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('')
|
||||
context.ref = 'refs/tags/sha-tag'
|
||||
expect(inputs.updatedReleaseName).toBe('sha-tag')
|
||||
it("returns tag", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("false").mockReturnValueOnce("")
|
||||
context.ref = "refs/tags/sha-tag"
|
||||
expect(inputs.updatedReleaseName).toBe("sha-tag")
|
||||
})
|
||||
})
|
||||
|
||||
describe('updatedPrerelease', () => {
|
||||
it('returns false', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('false')
|
||||
describe("updatedPrerelease", () => {
|
||||
it("returns false", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("false")
|
||||
expect(inputs.updatedPrerelease).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('false')
|
||||
.mockReturnValueOnce('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValueOnce("false").mockReturnValueOnce("true")
|
||||
expect(inputs.updatedPrerelease).toBe(true)
|
||||
})
|
||||
|
||||
it('returns undefined when omitted for update', () => {
|
||||
mockGetInput
|
||||
.mockReturnValueOnce('true')
|
||||
.mockReturnValueOnce('false')
|
||||
it("returns undefined when omitted for update", () => {
|
||||
mockGetInput.mockReturnValueOnce("true").mockReturnValueOnce("false")
|
||||
expect(inputs.updatedPrerelease).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('updateOnlyUnreleased', () => {
|
||||
it('returns false', () => {
|
||||
describe("updateOnlyUnreleased", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.updateOnlyUnreleased).toBe(false)
|
||||
})
|
||||
|
||||
it('returns true', () => {
|
||||
mockGetInput.mockReturnValueOnce('true')
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValueOnce("true")
|
||||
expect(inputs.updateOnlyUnreleased).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("omitBodyDuringUpdate", () => {
|
||||
it("returns false", () => {
|
||||
expect(inputs.omitBodyDuringUpdate).toBe(false)
|
||||
})
|
||||
|
||||
it("returns true", () => {
|
||||
mockGetInput.mockReturnValueOnce("true")
|
||||
expect(inputs.omitBodyDuringUpdate).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
function createGlobber(): ArtifactGlobber {
|
||||
const MockGlobber = jest.fn<ArtifactGlobber, any>(() => {
|
||||
return {
|
||||
globArtifactString: mockGlob
|
||||
globArtifactString: mockGlob,
|
||||
}
|
||||
})
|
||||
mockGlob.mockImplementation(() => artifacts)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import {Action} from "../src/Action";
|
||||
import * as github from "@actions/github";
|
||||
import {Inputs} from "../src/Inputs";
|
||||
import {GithubReleases, ReleaseData} from "../src/Releases";
|
||||
import {GithubArtifactUploader} from "../src/ArtifactUploader";
|
||||
import * as path from "path";
|
||||
import {FileArtifactGlobber} from "../src/ArtifactGlobber";
|
||||
import {Outputs} from "../src/Outputs";
|
||||
import {GithubArtifactDestroyer} from "../src/ArtifactDestroyer";
|
||||
import {ReleaseActionSkipper} from "../src/ActionSkipper";
|
||||
import { Action } from "../src/Action"
|
||||
import * as github from "@actions/github"
|
||||
import { Inputs } from "../src/Inputs"
|
||||
import { GithubReleases, ReleaseData } from "../src/Releases"
|
||||
import { GithubArtifactUploader } from "../src/ArtifactUploader"
|
||||
import * as path from "path"
|
||||
import { FileArtifactGlobber } from "../src/ArtifactGlobber"
|
||||
import { Outputs } from "../src/Outputs"
|
||||
import { GithubArtifactDestroyer } from "../src/ArtifactDestroyer"
|
||||
import { ReleaseActionSkipper } from "../src/ActionSkipper"
|
||||
|
||||
// This test is currently intended to be manually run during development. To run:
|
||||
// - Make sure you have an environment variable named GITHUB_TOKEN assigned to your token
|
||||
// - Remove skip from the test below
|
||||
describe.skip('Integration Test', () => {
|
||||
describe.skip("Integration Test", () => {
|
||||
let action: Action
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -22,18 +22,14 @@ describe.skip('Integration Test', () => {
|
||||
const inputs = getInputs()
|
||||
const outputs = getOutputs()
|
||||
const releases = new GithubReleases(inputs, git)
|
||||
const uploader = new GithubArtifactUploader(
|
||||
releases,
|
||||
inputs.replacesArtifacts,
|
||||
inputs.artifactErrorsFailBuild,
|
||||
)
|
||||
const uploader = new GithubArtifactUploader(releases, inputs.replacesArtifacts, inputs.artifactErrorsFailBuild)
|
||||
const artifactDestroyer = new GithubArtifactDestroyer(releases)
|
||||
const actionSkipper = new ReleaseActionSkipper(inputs.skipIfReleaseExists, releases, inputs.tag)
|
||||
|
||||
|
||||
action = new Action(inputs, outputs, releases, uploader, artifactDestroyer, actionSkipper)
|
||||
})
|
||||
|
||||
it('Performs action', async () => {
|
||||
it("Performs action", async () => {
|
||||
await action.perform()
|
||||
})
|
||||
|
||||
@@ -47,8 +43,9 @@ describe.skip('Integration Test', () => {
|
||||
createdReleaseBody: "This release was generated by release-action's integration test",
|
||||
createdReleaseName: "Releases Action Integration Test",
|
||||
commit: undefined,
|
||||
discussionCategory: 'Release',
|
||||
discussionCategory: "Release",
|
||||
generateReleaseNotes: true,
|
||||
omitBodyDuringUpdate: false,
|
||||
owner: "ncipollo",
|
||||
createdPrerelease: false,
|
||||
replacesArtifacts: true,
|
||||
@@ -61,10 +58,10 @@ describe.skip('Integration Test', () => {
|
||||
updatedReleaseBody: "This release was updated by release-action's integration test",
|
||||
updatedReleaseName: "Releases Action Integration Test",
|
||||
updatedPrerelease: false,
|
||||
updateOnlyUnreleased: false
|
||||
updateOnlyUnreleased: false,
|
||||
}
|
||||
})
|
||||
return new MockInputs();
|
||||
return new MockInputs()
|
||||
}
|
||||
|
||||
function getOutputs(): Outputs {
|
||||
@@ -72,7 +69,7 @@ describe.skip('Integration Test', () => {
|
||||
return {
|
||||
applyReleaseData(releaseData: ReleaseData) {
|
||||
console.log(`Release Data: ${releaseData}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
return new MockOutputs()
|
||||
@@ -80,7 +77,7 @@ describe.skip('Integration Test', () => {
|
||||
|
||||
function artifacts() {
|
||||
const globber = new FileArtifactGlobber()
|
||||
const artifactPath = path.join(__dirname, 'Integration.test.ts')
|
||||
const artifactPath = path.join(__dirname, "Integration.test.ts")
|
||||
const artifactString = `~/Desktop,~/Desktop/test.txt,blarg.tx, ${artifactPath}`
|
||||
return globber.globArtifactString(artifactString, "raw", false)
|
||||
}
|
||||
@@ -88,5 +85,4 @@ describe.skip('Integration Test', () => {
|
||||
function getToken(): string {
|
||||
return process.env.GITHUB_TOKEN ?? ""
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -1,29 +1,51 @@
|
||||
const mockSetOutput = jest.fn();
|
||||
const mockSetOutput = jest.fn()
|
||||
|
||||
import {CoreOutputs, Outputs} from "../src/Outputs";
|
||||
import {ReleaseData} from "../src/Releases";
|
||||
import { CoreOutputs, Outputs } from "../src/Outputs"
|
||||
import { ReleaseData } from "../src/Releases"
|
||||
|
||||
jest.mock('@actions/core', () => {
|
||||
return {setOutput: mockSetOutput};
|
||||
jest.mock("@actions/core", () => {
|
||||
return { setOutput: mockSetOutput }
|
||||
})
|
||||
|
||||
describe('Outputs', () => {
|
||||
let outputs: Outputs;
|
||||
const TEST_URLS = {
|
||||
HTML_URL: "https://api.example.com/assets",
|
||||
UPLOAD_URL: "https://api.example.com",
|
||||
TARBALL_URL: "https://api.example.com/tarball",
|
||||
ZIPBALL_URL: "https://api.example.com/zipball",
|
||||
} as const
|
||||
|
||||
describe("Outputs", () => {
|
||||
let outputs: Outputs
|
||||
let releaseData: ReleaseData
|
||||
|
||||
beforeEach(() => {
|
||||
outputs = new CoreOutputs()
|
||||
releaseData = {
|
||||
id: 1,
|
||||
html_url: 'https://api.example.com/assets',
|
||||
upload_url: 'https://api.example.com'
|
||||
html_url: TEST_URLS.HTML_URL,
|
||||
upload_url: TEST_URLS.UPLOAD_URL,
|
||||
tarball_url: TEST_URLS.TARBALL_URL,
|
||||
zipball_url: TEST_URLS.ZIPBALL_URL,
|
||||
}
|
||||
})
|
||||
|
||||
it('Applies the release data to the action output', () => {
|
||||
it("Applies the release data to the action output", () => {
|
||||
outputs.applyReleaseData(releaseData)
|
||||
expect(mockSetOutput).toBeCalledWith('id', releaseData.id)
|
||||
expect(mockSetOutput).toBeCalledWith('html_url', releaseData.html_url)
|
||||
expect(mockSetOutput).toBeCalledWith('upload_url', releaseData.upload_url)
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("id", releaseData.id)
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("html_url", releaseData.html_url)
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("upload_url", releaseData.upload_url)
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("tarball_url", releaseData.tarball_url)
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("zipball_url", releaseData.zipball_url)
|
||||
})
|
||||
|
||||
it("Handles null tarball_url and zipball_url", () => {
|
||||
const releaseDataWithNulls = {
|
||||
...releaseData,
|
||||
tarball_url: null,
|
||||
zipball_url: null,
|
||||
}
|
||||
outputs.applyReleaseData(releaseDataWithNulls)
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("tarball_url", "")
|
||||
expect(mockSetOutput).toHaveBeenCalledWith("zipball_url", "")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {ReleaseValidator} from "../src/ReleaseValidator";
|
||||
import { ReleaseValidator } from "../src/ReleaseValidator"
|
||||
|
||||
describe("validateReleaseUpdate", () => {
|
||||
describe("updateOnlyUnreleased is disabled", () => {
|
||||
const validator = new ReleaseValidator(false)
|
||||
it('should not throw', () => {
|
||||
it("should not throw", () => {
|
||||
const releaseResponse = {
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
name: "Name"
|
||||
name: "Name",
|
||||
}
|
||||
expect(() => {
|
||||
validator.validateReleaseUpdate(releaseResponse)
|
||||
@@ -16,59 +16,59 @@ describe("validateReleaseUpdate", () => {
|
||||
})
|
||||
describe("updateOnlyUnreleased is enabled", () => {
|
||||
const validator = new ReleaseValidator(true)
|
||||
it('should throw if neither draft or prerelease are enabled', () => {
|
||||
it("should throw if neither draft or prerelease are enabled", () => {
|
||||
const releaseResponse = {
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
name: "Name"
|
||||
name: "Name",
|
||||
}
|
||||
expect(() => {
|
||||
validator.validateReleaseUpdate(releaseResponse)
|
||||
}).toThrow()
|
||||
})
|
||||
|
||||
it('should not throw if draft is enabled', () => {
|
||||
|
||||
it("should not throw if draft is enabled", () => {
|
||||
const releaseResponse = {
|
||||
draft: true,
|
||||
prerelease: false,
|
||||
name: "Name"
|
||||
name: "Name",
|
||||
}
|
||||
expect(() => {
|
||||
validator.validateReleaseUpdate(releaseResponse)
|
||||
}).not.toThrow()
|
||||
})
|
||||
|
||||
it('should not throw if prerelease is enabled', () => {
|
||||
it("should not throw if prerelease is enabled", () => {
|
||||
const releaseResponse = {
|
||||
draft: false,
|
||||
prerelease: true,
|
||||
name: "Name"
|
||||
name: "Name",
|
||||
}
|
||||
expect(() => {
|
||||
validator.validateReleaseUpdate(releaseResponse)
|
||||
}).not.toThrow()
|
||||
})
|
||||
|
||||
it('should not throw if draft & prerelease is enabled', () => {
|
||||
it("should not throw if draft & prerelease is enabled", () => {
|
||||
const releaseResponse = {
|
||||
draft: true,
|
||||
prerelease: true,
|
||||
name: "Name"
|
||||
name: "Name",
|
||||
}
|
||||
expect(() => {
|
||||
validator.validateReleaseUpdate(releaseResponse)
|
||||
}).not.toThrow()
|
||||
})
|
||||
|
||||
it('should default error message release name to release', () => {
|
||||
it("should default error message release name to release", () => {
|
||||
const releaseResponse = {
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
name: null
|
||||
name: null,
|
||||
}
|
||||
expect(() => {
|
||||
validator.validateReleaseUpdate(releaseResponse)
|
||||
}).toThrow(`Tried to update "release" which is neither a draft or prerelease. (updateOnlyUnreleased is on)`)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
35
biome.json
Normal file
35
biome.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"vcs": {
|
||||
"enabled": false,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"ignore": ["node_modules/**/*", "dist/"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"formatWithErrors": false,
|
||||
"indentStyle": "space",
|
||||
"lineEnding": "lf",
|
||||
"indentWidth": 4,
|
||||
"lineWidth": 120
|
||||
},
|
||||
"organizeImports": { "enabled": true },
|
||||
"linter": {
|
||||
"enabled": false,
|
||||
"rules": {
|
||||
"recommended": true
|
||||
}
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "double",
|
||||
"trailingCommas": "es5",
|
||||
"semicolons": "asNeeded",
|
||||
"indentWidth": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
2044
dist/index.js
vendored
2044
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/sourcemap-register.js
vendored
2
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
134
package.json
134
package.json
@@ -1,76 +1,66 @@
|
||||
{
|
||||
"name": "release-action",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"description": "An action which manages a github release",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rm -rf lib/*",
|
||||
"coverage": "jest --coverage",
|
||||
"debug": "yarn clean && yarn install && yarn build && yarn package",
|
||||
"package": "ncc build --source-map --license licenses.txt",
|
||||
"release": "yarn clean && yarn install --production && yarn build && yarn package",
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ncipollo/release-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
"node",
|
||||
"setup"
|
||||
],
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"jest": {
|
||||
"clearMocks": true,
|
||||
"collectCoverage": true,
|
||||
"coveragePathIgnorePatterns": [
|
||||
"src/Globber.ts",
|
||||
"src/Releases.ts"
|
||||
],
|
||||
"coverageThreshold": {
|
||||
"global": {
|
||||
"branches": 95,
|
||||
"functions": 100,
|
||||
"lines": 100,
|
||||
"statements": 100
|
||||
}
|
||||
"name": "release-action",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"description": "An action which manages a github release",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rm -rf lib/*",
|
||||
"coverage": "jest --coverage",
|
||||
"debug": "yarn clean && yarn install && yarn build && yarn package",
|
||||
"format": "yarn biome format --write .",
|
||||
"package": "ncc build --source-map --license licenses.txt",
|
||||
"release": "yarn clean && yarn install --production && yarn build && yarn package",
|
||||
"test": "jest"
|
||||
},
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"ts"
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"**/*.test.ts"
|
||||
],
|
||||
"testRunner": "jest-circus/runner",
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ncipollo/release-action.git"
|
||||
},
|
||||
"verbose": true
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@types/node": "^22.10.3",
|
||||
"glob": "^11.0.0",
|
||||
"untildify": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^5.7.3"
|
||||
},
|
||||
"resolutions": {
|
||||
"jest-cli/yargs": "^17.3.1"
|
||||
}
|
||||
"keywords": ["actions", "node", "setup"],
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"jest": {
|
||||
"clearMocks": true,
|
||||
"collectCoverage": true,
|
||||
"coveragePathIgnorePatterns": ["src/Globber.ts", "src/Releases.ts"],
|
||||
"coverageThreshold": {
|
||||
"global": {
|
||||
"branches": 95,
|
||||
"functions": 100,
|
||||
"lines": 100,
|
||||
"statements": 100
|
||||
}
|
||||
},
|
||||
"moduleFileExtensions": ["js", "ts"],
|
||||
"testEnvironment": "node",
|
||||
"testMatch": ["**/*.test.ts"],
|
||||
"testRunner": "jest-circus/runner",
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
},
|
||||
"verbose": true
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.1",
|
||||
"@types/node": "^22.15.29",
|
||||
"glob": "^11.0.2",
|
||||
"untildify": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@types/jest": "^29.5.14",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"ts-jest": "^29.3.4",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"resolutions": {
|
||||
"jest-cli/yargs": "^17.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
6
sheepit.toml
Normal file
6
sheepit.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[repository]
|
||||
enable_commit = true
|
||||
tag_pattern = "v{version}"
|
||||
|
||||
[scripts]
|
||||
before_commit = "yarn release"
|
||||
@@ -1,18 +1,18 @@
|
||||
import * as core from '@actions/core';
|
||||
import {Inputs} from "./Inputs";
|
||||
import {
|
||||
import * as core from "@actions/core"
|
||||
import type { ActionSkipper } from "./ActionSkipper"
|
||||
import type { ArtifactDestroyer } from "./ArtifactDestroyer"
|
||||
import type { ArtifactUploader } from "./ArtifactUploader"
|
||||
import { GithubError } from "./GithubError"
|
||||
import type { Inputs } from "./Inputs"
|
||||
import type { Outputs } from "./Outputs"
|
||||
import { ReleaseValidator } from "./ReleaseValidator"
|
||||
import type {
|
||||
CreateOrUpdateReleaseResponse,
|
||||
CreateReleaseResponse,
|
||||
ReleaseByTagResponse,
|
||||
Releases,
|
||||
UpdateReleaseResponse
|
||||
} from "./Releases";
|
||||
import {ArtifactUploader} from "./ArtifactUploader";
|
||||
import {GithubError} from "./GithubError";
|
||||
import {Outputs} from "./Outputs";
|
||||
import {ArtifactDestroyer} from "./ArtifactDestroyer";
|
||||
import {ReleaseValidator} from "./ReleaseValidator";
|
||||
import {ActionSkipper} from "./ActionSkipper";
|
||||
UpdateReleaseResponse,
|
||||
} from "./Releases"
|
||||
|
||||
export class Action {
|
||||
private inputs: Inputs
|
||||
@@ -21,15 +21,17 @@ export class Action {
|
||||
private uploader: ArtifactUploader
|
||||
private artifactDestroyer: ArtifactDestroyer
|
||||
private skipper: ActionSkipper
|
||||
|
||||
|
||||
private releaseValidator: ReleaseValidator
|
||||
|
||||
constructor(inputs: Inputs,
|
||||
outputs: Outputs,
|
||||
releases: Releases,
|
||||
uploader: ArtifactUploader,
|
||||
artifactDestroyer: ArtifactDestroyer,
|
||||
skipper: ActionSkipper) {
|
||||
constructor(
|
||||
inputs: Inputs,
|
||||
outputs: Outputs,
|
||||
releases: Releases,
|
||||
uploader: ArtifactUploader,
|
||||
artifactDestroyer: ArtifactDestroyer,
|
||||
skipper: ActionSkipper
|
||||
) {
|
||||
this.inputs = inputs
|
||||
this.outputs = outputs
|
||||
this.releases = releases
|
||||
@@ -44,16 +46,16 @@ export class Action {
|
||||
core.notice("Skipping action, release already exists and skipIfReleaseExists is enabled.")
|
||||
return
|
||||
}
|
||||
|
||||
const releaseResponse = await this.createOrUpdateRelease();
|
||||
|
||||
const releaseResponse = await this.createOrUpdateRelease()
|
||||
const releaseData = releaseResponse.data
|
||||
const releaseId = releaseData.id
|
||||
const uploadUrl = releaseData.upload_url
|
||||
|
||||
|
||||
if (this.inputs.removeArtifacts) {
|
||||
await this.artifactDestroyer.destroyArtifacts(releaseId)
|
||||
}
|
||||
|
||||
|
||||
const artifacts = this.inputs.artifacts
|
||||
if (artifacts.length > 0) {
|
||||
await this.uploader.uploadArtifacts(artifacts, releaseId, uploadUrl)
|
||||
@@ -70,7 +72,7 @@ export class Action {
|
||||
} catch (error: any) {
|
||||
return await this.checkForMissingReleaseError(error)
|
||||
}
|
||||
|
||||
|
||||
// Fail if this isn't an unreleased release & updateOnlyUnreleased is enabled.
|
||||
this.releaseValidator.validateReleaseUpdate(getResponse.data)
|
||||
|
||||
@@ -89,10 +91,17 @@ export class Action {
|
||||
}
|
||||
|
||||
private async updateRelease(id: number): Promise<UpdateReleaseResponse> {
|
||||
let releaseBody = this.inputs.updatedReleaseBody
|
||||
|
||||
if (this.inputs.generateReleaseNotes && !this.inputs.omitBodyDuringUpdate) {
|
||||
const response = await this.releases.generateReleaseNotes(this.inputs.tag)
|
||||
releaseBody = response.data.body
|
||||
}
|
||||
|
||||
return await this.releases.update(
|
||||
id,
|
||||
this.inputs.tag,
|
||||
this.inputs.updatedReleaseBody,
|
||||
releaseBody,
|
||||
this.inputs.commit,
|
||||
this.inputs.discussionCategory,
|
||||
this.inputs.updatedDraft,
|
||||
@@ -120,11 +129,11 @@ export class Action {
|
||||
const tag = this.inputs.tag
|
||||
const response = await this.releases.listReleases()
|
||||
const releases = response.data
|
||||
if(!releases) {
|
||||
if (!releases) {
|
||||
throw new Error(`No releases found. Response: ${JSON.stringify(response)}`)
|
||||
}
|
||||
|
||||
const draftRelease = releases.find(release => release.draft && release.tag_name == tag)
|
||||
const draftRelease = releases.find((release) => release.draft && release.tag_name == tag)
|
||||
|
||||
return draftRelease?.id
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import {Releases} from "./Releases";
|
||||
import { Releases } from "./Releases"
|
||||
|
||||
export interface ActionSkipper {
|
||||
shouldSkip(): Promise<boolean>
|
||||
}
|
||||
|
||||
export class ReleaseActionSkipper {
|
||||
constructor(private skipIfReleaseExists: boolean,
|
||||
private releases: Releases,
|
||||
private tag: string) {
|
||||
}
|
||||
constructor(
|
||||
private skipIfReleaseExists: boolean,
|
||||
private releases: Releases,
|
||||
private tag: string
|
||||
) {}
|
||||
|
||||
async shouldSkip(): Promise<boolean> {
|
||||
if (!this.skipIfReleaseExists) {
|
||||
// Bail if skip flag isn't set.
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -21,7 +22,7 @@ export class ReleaseActionSkipper {
|
||||
return getResponse.data != null
|
||||
} catch (error: any) {
|
||||
// There is either no release or something else went wrong. Either way, run the action.
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { basename } from "path";
|
||||
import {createReadStream, readFileSync, ReadStream, statSync} from "fs";
|
||||
import { basename } from "path"
|
||||
import { createReadStream, readFileSync, ReadStream, statSync } from "fs"
|
||||
|
||||
export class Artifact {
|
||||
readonly contentType: string
|
||||
@@ -9,7 +9,7 @@ export class Artifact {
|
||||
constructor(path: string, contentType: string = "raw") {
|
||||
this.path = path
|
||||
this.name = basename(path)
|
||||
this.contentType = contentType;
|
||||
this.contentType = contentType
|
||||
}
|
||||
|
||||
get contentLength(): number {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import {Releases} from "./Releases";
|
||||
import * as core from "@actions/core";
|
||||
import { Releases } from "./Releases"
|
||||
import * as core from "@actions/core"
|
||||
|
||||
export interface ArtifactDestroyer {
|
||||
destroyArtifacts(releaseId: number): Promise<void>
|
||||
}
|
||||
|
||||
export class GithubArtifactDestroyer implements ArtifactDestroyer {
|
||||
constructor(private releases: Releases) {
|
||||
}
|
||||
constructor(private releases: Releases) {}
|
||||
|
||||
async destroyArtifacts(releaseId: number): Promise<void> {
|
||||
const releaseAssets = await this.releases.listArtifactsForRelease(releaseId)
|
||||
@@ -17,4 +16,4 @@ export class GithubArtifactDestroyer implements ArtifactDestroyer {
|
||||
await this.releases.deleteArtifact(asset.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as core from '@actions/core';
|
||||
import {Globber, FileGlobber} from "./Globber";
|
||||
import {Artifact} from "./Artifact";
|
||||
import untildify from "untildify";
|
||||
import {ArtifactPathValidator} from "./ArtifactPathValidator";
|
||||
import {PathNormalizer} from "./PathNormalizer";
|
||||
import * as core from "@actions/core"
|
||||
import { Globber, FileGlobber } from "./Globber"
|
||||
import { Artifact } from "./Artifact"
|
||||
import untildify from "untildify"
|
||||
import { ArtifactPathValidator } from "./ArtifactPathValidator"
|
||||
import { PathNormalizer } from "./PathNormalizer"
|
||||
|
||||
export interface ArtifactGlobber {
|
||||
globArtifactString(artifact: string, contentType: string, errorsFailBuild: boolean): Artifact[]
|
||||
@@ -18,14 +18,15 @@ export class FileArtifactGlobber implements ArtifactGlobber {
|
||||
|
||||
globArtifactString(artifact: string, contentType: string, errorsFailBuild: boolean): Artifact[] {
|
||||
const split = /[,\n]/
|
||||
return artifact.split(split)
|
||||
.map(path => path.trimStart())
|
||||
.map(path => PathNormalizer.normalizePath(path))
|
||||
.map(path => FileArtifactGlobber.expandPath(path))
|
||||
.map(pattern => this.globPattern(pattern, errorsFailBuild))
|
||||
return artifact
|
||||
.split(split)
|
||||
.map((path) => path.trimStart())
|
||||
.map((path) => PathNormalizer.normalizePath(path))
|
||||
.map((path) => FileArtifactGlobber.expandPath(path))
|
||||
.map((pattern) => this.globPattern(pattern, errorsFailBuild))
|
||||
.map((globResult) => FileArtifactGlobber.validatePattern(errorsFailBuild, globResult[1], globResult[0]))
|
||||
.reduce((accumulated, current) => accumulated.concat(current))
|
||||
.map(path => new Artifact(path, contentType))
|
||||
.map((path) => new Artifact(path, contentType))
|
||||
}
|
||||
|
||||
private globPattern(pattern: string, errorsFailBuild: boolean): [string, string[]] {
|
||||
@@ -56,4 +57,4 @@ export class FileArtifactGlobber implements ArtifactGlobber {
|
||||
private static expandPath(path: string): string {
|
||||
return untildify(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import * as core from "@actions/core";
|
||||
import {statSync} from "fs";
|
||||
import * as core from "@actions/core"
|
||||
import { statSync } from "fs"
|
||||
|
||||
export class ArtifactPathValidator {
|
||||
private readonly errorsFailBuild: boolean;
|
||||
private paths: string[];
|
||||
private readonly errorsFailBuild: boolean
|
||||
private paths: string[]
|
||||
private readonly pattern: string
|
||||
|
||||
|
||||
constructor(errorsFailBuild: boolean, paths: string[], pattern: string) {
|
||||
this.paths = paths;
|
||||
this.paths = paths
|
||||
this.pattern = pattern
|
||||
this.errorsFailBuild = errorsFailBuild;
|
||||
this.errorsFailBuild = errorsFailBuild
|
||||
}
|
||||
|
||||
|
||||
validate(): string[] {
|
||||
this.verifyPathsNotEmpty()
|
||||
return this.paths.filter((path) => this.verifyNotDirectory(path))
|
||||
}
|
||||
|
||||
|
||||
private verifyPathsNotEmpty() {
|
||||
if (this.paths.length == 0) {
|
||||
const message = `Artifact pattern:${this.pattern} did not match any files`
|
||||
this.reportError(message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private verifyNotDirectory(path: string): boolean {
|
||||
const isDir = statSync(path).isDirectory()
|
||||
if (isDir) {
|
||||
@@ -32,7 +32,7 @@ export class ArtifactPathValidator {
|
||||
}
|
||||
return !isDir
|
||||
}
|
||||
|
||||
|
||||
private reportError(message: string) {
|
||||
if (this.errorsFailBuild) {
|
||||
throw Error(message)
|
||||
@@ -40,4 +40,4 @@ export class ArtifactPathValidator {
|
||||
core.warning(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as core from '@actions/core';
|
||||
import {Artifact} from "./Artifact";
|
||||
import {Releases} from "./Releases";
|
||||
import * as core from "@actions/core"
|
||||
import { Artifact } from "./Artifact"
|
||||
import { Releases } from "./Releases"
|
||||
|
||||
export interface ArtifactUploader {
|
||||
uploadArtifacts(artifacts: Artifact[], releaseId: number, uploadUrl: string): Promise<void>
|
||||
@@ -10,13 +10,10 @@ export class GithubArtifactUploader implements ArtifactUploader {
|
||||
constructor(
|
||||
private releases: Releases,
|
||||
private replacesExistingArtifacts: boolean = true,
|
||||
private throwsUploadErrors: boolean = false,
|
||||
) {
|
||||
}
|
||||
private throwsUploadErrors: boolean = false
|
||||
) {}
|
||||
|
||||
async uploadArtifacts(artifacts: Artifact[],
|
||||
releaseId: number,
|
||||
uploadUrl: string): Promise<void> {
|
||||
async uploadArtifacts(artifacts: Artifact[], releaseId: number, uploadUrl: string): Promise<void> {
|
||||
if (this.replacesExistingArtifacts) {
|
||||
await this.deleteUpdatedArtifacts(artifacts, releaseId)
|
||||
}
|
||||
@@ -25,18 +22,17 @@ export class GithubArtifactUploader implements ArtifactUploader {
|
||||
}
|
||||
}
|
||||
|
||||
private async uploadArtifact(artifact: Artifact,
|
||||
releaseId: number,
|
||||
uploadUrl: string,
|
||||
retry = 3) {
|
||||
private async uploadArtifact(artifact: Artifact, releaseId: number, uploadUrl: string, retry = 3) {
|
||||
try {
|
||||
core.debug(`Uploading artifact ${artifact.name}...`)
|
||||
await this.releases.uploadArtifact(uploadUrl,
|
||||
await this.releases.uploadArtifact(
|
||||
uploadUrl,
|
||||
artifact.contentLength,
|
||||
artifact.contentType,
|
||||
artifact.readFile(),
|
||||
artifact.name,
|
||||
releaseId)
|
||||
releaseId
|
||||
)
|
||||
} catch (error: any) {
|
||||
if (error.status >= 500 && retry > 0) {
|
||||
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}. Retrying...`)
|
||||
@@ -54,9 +50,9 @@ export class GithubArtifactUploader implements ArtifactUploader {
|
||||
private async deleteUpdatedArtifacts(artifacts: Artifact[], releaseId: number): Promise<void> {
|
||||
const releaseAssets = await this.releases.listArtifactsForRelease(releaseId)
|
||||
const assetByName: Record<string, { id: number; name: string }> = {}
|
||||
releaseAssets.forEach(asset => {
|
||||
releaseAssets.forEach((asset) => {
|
||||
assetByName[asset.name] = asset
|
||||
});
|
||||
})
|
||||
for (const artifact of artifacts) {
|
||||
const asset = assetByName[artifact.name]
|
||||
if (asset) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {GithubErrorDetail} from "./GithubErrorDetail"
|
||||
import { GithubErrorDetail } from "./GithubErrorDetail"
|
||||
|
||||
export class GithubError {
|
||||
private error: any
|
||||
@@ -40,7 +40,7 @@ export class GithubError {
|
||||
private errorBulletedList(errors: GithubErrorDetail[]): string {
|
||||
return errors.map((err) => `- ${err}`).join("\n")
|
||||
}
|
||||
|
||||
|
||||
private remediation(): String {
|
||||
if (this.status == 404) {
|
||||
return "\nMake sure your github token has access to the repo and has permission to author releases"
|
||||
@@ -48,4 +48,3 @@ export class GithubError {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class GithubErrorDetail {
|
||||
private error: any;
|
||||
private error: any
|
||||
|
||||
constructor(error: any) {
|
||||
this.error = error
|
||||
@@ -12,13 +12,13 @@ export class GithubErrorDetail {
|
||||
toString(): string {
|
||||
const code = this.error.code
|
||||
switch (code) {
|
||||
case 'missing':
|
||||
case "missing":
|
||||
return this.missingResourceMessage()
|
||||
case 'missing_field':
|
||||
case "missing_field":
|
||||
return this.missingFieldMessage()
|
||||
case 'invalid':
|
||||
case "invalid":
|
||||
return this.invalidFieldMessage()
|
||||
case 'already_exists':
|
||||
case "already_exists":
|
||||
return this.resourceAlreadyExists()
|
||||
default:
|
||||
return this.customErrorMessage()
|
||||
@@ -26,7 +26,7 @@ export class GithubErrorDetail {
|
||||
}
|
||||
|
||||
private customErrorMessage(): string {
|
||||
const message = this.error.message;
|
||||
const message = this.error.message
|
||||
const documentation = this.error.documentation_url
|
||||
|
||||
let documentationMessage: string
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {globSync} from "glob";
|
||||
|
||||
import { globSync } from "glob"
|
||||
|
||||
export interface Globber {
|
||||
glob(pattern: string): string[]
|
||||
@@ -9,4 +8,4 @@ export class FileGlobber implements Globber {
|
||||
glob(pattern: string): string[] {
|
||||
return globSync(pattern, { mark: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
102
src/Inputs.ts
102
src/Inputs.ts
@@ -1,8 +1,8 @@
|
||||
import * as core from '@actions/core';
|
||||
import {Context} from "@actions/github/lib/context";
|
||||
import {readFileSync} from 'fs';
|
||||
import {ArtifactGlobber} from './ArtifactGlobber';
|
||||
import {Artifact} from './Artifact';
|
||||
import * as core from "@actions/core"
|
||||
import { Context } from "@actions/github/lib/context"
|
||||
import { readFileSync } from "fs"
|
||||
import { ArtifactGlobber } from "./ArtifactGlobber"
|
||||
import { Artifact } from "./Artifact"
|
||||
|
||||
export interface Inputs {
|
||||
readonly allowUpdates: boolean
|
||||
@@ -16,6 +16,7 @@ export interface Inputs {
|
||||
readonly discussionCategory?: string
|
||||
readonly generateReleaseNotes: boolean
|
||||
readonly makeLatest?: "legacy" | "true" | "false" | undefined
|
||||
readonly omitBodyDuringUpdate: boolean
|
||||
readonly owner: string
|
||||
readonly removeArtifacts: boolean
|
||||
readonly replacesArtifacts: boolean
|
||||
@@ -40,53 +41,52 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
get allowUpdates(): boolean {
|
||||
const allow = core.getInput('allowUpdates')
|
||||
return allow == 'true'
|
||||
const allow = core.getInput("allowUpdates")
|
||||
return allow == "true"
|
||||
}
|
||||
|
||||
get artifacts(): Artifact[] {
|
||||
let artifacts = core.getInput('artifacts')
|
||||
let artifacts = core.getInput("artifacts")
|
||||
if (!artifacts) {
|
||||
artifacts = core.getInput('artifact')
|
||||
artifacts = core.getInput("artifact")
|
||||
}
|
||||
if (artifacts) {
|
||||
let contentType = core.getInput('artifactContentType')
|
||||
let contentType = core.getInput("artifactContentType")
|
||||
if (!contentType) {
|
||||
contentType = 'raw'
|
||||
contentType = "raw"
|
||||
}
|
||||
return this.artifactGlobber
|
||||
.globArtifactString(artifacts, contentType, this.artifactErrorsFailBuild)
|
||||
return this.artifactGlobber.globArtifactString(artifacts, contentType, this.artifactErrorsFailBuild)
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
get artifactErrorsFailBuild(): boolean {
|
||||
const allow = core.getInput('artifactErrorsFailBuild')
|
||||
return allow == 'true'
|
||||
const allow = core.getInput("artifactErrorsFailBuild")
|
||||
return allow == "true"
|
||||
}
|
||||
|
||||
private get body(): string | undefined {
|
||||
const body = core.getInput('body')
|
||||
const body = core.getInput("body")
|
||||
if (body) {
|
||||
return body
|
||||
}
|
||||
|
||||
const bodyFile = core.getInput('bodyFile')
|
||||
const bodyFile = core.getInput("bodyFile")
|
||||
if (bodyFile) {
|
||||
return this.stringFromFile(bodyFile)
|
||||
}
|
||||
|
||||
return ''
|
||||
return ""
|
||||
}
|
||||
|
||||
get createdDraft(): boolean {
|
||||
const draft = core.getInput('draft')
|
||||
return draft == 'true'
|
||||
const draft = core.getInput("draft")
|
||||
return draft == "true"
|
||||
}
|
||||
|
||||
get createdPrerelease(): boolean {
|
||||
const preRelease = core.getInput('prerelease')
|
||||
return preRelease == 'true'
|
||||
const preRelease = core.getInput("prerelease")
|
||||
return preRelease == "true"
|
||||
}
|
||||
|
||||
get createdReleaseBody(): string | undefined {
|
||||
@@ -95,7 +95,7 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
private static get omitBody(): boolean {
|
||||
return core.getInput('omitBody') == 'true'
|
||||
return core.getInput("omitBody") == "true"
|
||||
}
|
||||
|
||||
get createdReleaseName(): string | undefined {
|
||||
@@ -104,11 +104,11 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
private static get omitName(): boolean {
|
||||
return core.getInput('omitName') == 'true'
|
||||
return core.getInput("omitName") == "true"
|
||||
}
|
||||
|
||||
get commit(): string | undefined {
|
||||
const commit = core.getInput('commit')
|
||||
const commit = core.getInput("commit")
|
||||
if (commit) {
|
||||
return commit
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
get discussionCategory(): string | undefined {
|
||||
const category = core.getInput('discussionCategory')
|
||||
const category = core.getInput("discussionCategory")
|
||||
if (category) {
|
||||
return category
|
||||
}
|
||||
@@ -124,7 +124,7 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
private get name(): string | undefined {
|
||||
const name = core.getInput('name')
|
||||
const name = core.getInput("name")
|
||||
if (name) {
|
||||
return name
|
||||
}
|
||||
@@ -133,21 +133,21 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
get generateReleaseNotes(): boolean {
|
||||
const generate = core.getInput('generateReleaseNotes')
|
||||
return generate == 'true'
|
||||
const generate = core.getInput("generateReleaseNotes")
|
||||
return generate == "true"
|
||||
}
|
||||
|
||||
get makeLatest(): "legacy" | "true" | "false" | undefined {
|
||||
let latest = core.getInput('makeLatest')
|
||||
let latest = core.getInput("makeLatest")
|
||||
if (latest == "true" || latest == "false" || latest == "legacy") {
|
||||
return latest;
|
||||
return latest
|
||||
}
|
||||
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
get owner(): string {
|
||||
let owner = core.getInput('owner')
|
||||
let owner = core.getInput("owner")
|
||||
if (owner) {
|
||||
return owner
|
||||
}
|
||||
@@ -155,17 +155,17 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
get removeArtifacts(): boolean {
|
||||
const removes = core.getInput('removeArtifacts')
|
||||
return removes == 'true'
|
||||
const removes = core.getInput("removeArtifacts")
|
||||
return removes == "true"
|
||||
}
|
||||
|
||||
get replacesArtifacts(): boolean {
|
||||
const replaces = core.getInput('replacesArtifacts')
|
||||
return replaces == 'true'
|
||||
const replaces = core.getInput("replacesArtifacts")
|
||||
return replaces == "true"
|
||||
}
|
||||
|
||||
get repo(): string {
|
||||
let repo = core.getInput('repo')
|
||||
let repo = core.getInput("repo")
|
||||
if (repo) {
|
||||
return repo
|
||||
}
|
||||
@@ -177,9 +177,9 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
get tag(): string {
|
||||
const tag = core.getInput('tag')
|
||||
const tag = core.getInput("tag")
|
||||
if (tag) {
|
||||
return tag;
|
||||
return tag
|
||||
}
|
||||
|
||||
const ref = this.context.ref
|
||||
@@ -192,7 +192,7 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
get token(): string {
|
||||
return core.getInput('token', {required: true})
|
||||
return core.getInput("token", { required: true })
|
||||
}
|
||||
|
||||
get updatedDraft(): boolean | undefined {
|
||||
@@ -201,7 +201,7 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
private static get omitDraftDuringUpdate(): boolean {
|
||||
return core.getInput('omitDraftDuringUpdate') == 'true'
|
||||
return core.getInput("omitDraftDuringUpdate") == "true"
|
||||
}
|
||||
|
||||
get updatedPrerelease(): boolean | undefined {
|
||||
@@ -210,7 +210,7 @@ export class CoreInputs implements Inputs {
|
||||
}
|
||||
|
||||
private static get omitPrereleaseDuringUpdate(): boolean {
|
||||
return core.getInput('omitPrereleaseDuringUpdate') == 'true'
|
||||
return core.getInput("omitPrereleaseDuringUpdate") == "true"
|
||||
}
|
||||
|
||||
get updatedReleaseBody(): string | undefined {
|
||||
@@ -218,8 +218,8 @@ export class CoreInputs implements Inputs {
|
||||
return this.body
|
||||
}
|
||||
|
||||
private static get omitBodyDuringUpdate(): boolean {
|
||||
return core.getInput('omitBodyDuringUpdate') == 'true'
|
||||
get updateOnlyUnreleased(): boolean {
|
||||
return core.getInput("updateOnlyUnreleased") == "true"
|
||||
}
|
||||
|
||||
get updatedReleaseName(): string | undefined {
|
||||
@@ -227,15 +227,19 @@ export class CoreInputs implements Inputs {
|
||||
return this.name
|
||||
}
|
||||
|
||||
get updateOnlyUnreleased(): boolean {
|
||||
return core.getInput('updateOnlyUnreleased') == 'true'
|
||||
private static get omitBodyDuringUpdate(): boolean {
|
||||
return core.getInput("omitBodyDuringUpdate") == "true"
|
||||
}
|
||||
|
||||
get omitBodyDuringUpdate(): boolean {
|
||||
return CoreInputs.omitBodyDuringUpdate
|
||||
}
|
||||
|
||||
private static get omitNameDuringUpdate(): boolean {
|
||||
return core.getInput('omitNameDuringUpdate') == 'true'
|
||||
return core.getInput("omitNameDuringUpdate") == "true"
|
||||
}
|
||||
|
||||
stringFromFile(path: string): string {
|
||||
return readFileSync(path, 'utf-8')
|
||||
return readFileSync(path, "utf-8")
|
||||
}
|
||||
}
|
||||
|
||||
30
src/Main.ts
30
src/Main.ts
@@ -1,14 +1,14 @@
|
||||
import * as github from '@actions/github';
|
||||
import * as core from '@actions/core';
|
||||
import {CoreInputs} from './Inputs';
|
||||
import {GithubReleases} from './Releases';
|
||||
import {Action} from './Action';
|
||||
import {GithubArtifactUploader} from './ArtifactUploader';
|
||||
import {FileArtifactGlobber} from './ArtifactGlobber';
|
||||
import {GithubError} from './GithubError';
|
||||
import {CoreOutputs} from "./Outputs";
|
||||
import {GithubArtifactDestroyer} from "./ArtifactDestroyer";
|
||||
import {ActionSkipper, ReleaseActionSkipper} from "./ActionSkipper";
|
||||
import * as github from "@actions/github"
|
||||
import * as core from "@actions/core"
|
||||
import { CoreInputs } from "./Inputs"
|
||||
import { GithubReleases } from "./Releases"
|
||||
import { Action } from "./Action"
|
||||
import { GithubArtifactUploader } from "./ArtifactUploader"
|
||||
import { FileArtifactGlobber } from "./ArtifactGlobber"
|
||||
import { GithubError } from "./GithubError"
|
||||
import { CoreOutputs } from "./Outputs"
|
||||
import { GithubArtifactDestroyer } from "./ArtifactDestroyer"
|
||||
import { ActionSkipper, ReleaseActionSkipper } from "./ActionSkipper"
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
@@ -16,12 +16,12 @@ async function run() {
|
||||
await action.perform()
|
||||
} catch (error) {
|
||||
const githubError = new GithubError(error)
|
||||
core.setFailed(githubError.toString());
|
||||
core.setFailed(githubError.toString())
|
||||
}
|
||||
}
|
||||
|
||||
function createAction(): Action {
|
||||
const token = core.getInput('token')
|
||||
const token = core.getInput("token")
|
||||
const context = github.context
|
||||
const git = github.getOctokit(token)
|
||||
const globber = new FileArtifactGlobber()
|
||||
@@ -32,8 +32,8 @@ function createAction(): Action {
|
||||
const skipper = new ReleaseActionSkipper(inputs.skipIfReleaseExists, releases, inputs.tag)
|
||||
const uploader = new GithubArtifactUploader(releases, inputs.replacesArtifacts, inputs.artifactErrorsFailBuild)
|
||||
const artifactDestroyer = new GithubArtifactDestroyer(releases)
|
||||
|
||||
|
||||
return new Action(inputs, outputs, releases, uploader, artifactDestroyer, skipper)
|
||||
}
|
||||
|
||||
run();
|
||||
run()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as core from '@actions/core';
|
||||
import {ReleaseData} from "./Releases";
|
||||
import * as core from "@actions/core"
|
||||
import { ReleaseData } from "./Releases"
|
||||
|
||||
export interface Outputs {
|
||||
applyReleaseData(releaseData: ReleaseData): void
|
||||
@@ -7,8 +7,10 @@ export interface Outputs {
|
||||
|
||||
export class CoreOutputs implements Outputs {
|
||||
applyReleaseData(releaseData: ReleaseData) {
|
||||
core.setOutput('id', releaseData.id)
|
||||
core.setOutput('html_url', releaseData.html_url)
|
||||
core.setOutput('upload_url', releaseData.upload_url)
|
||||
core.setOutput("id", releaseData.id)
|
||||
core.setOutput("html_url", releaseData.html_url)
|
||||
core.setOutput("upload_url", releaseData.upload_url)
|
||||
core.setOutput("tarball_url", releaseData.tarball_url || "")
|
||||
core.setOutput("zipball_url", releaseData.zipball_url || "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import path from "path"
|
||||
|
||||
export class PathNormalizer {
|
||||
static normalizePath(pathString: string): string {
|
||||
return pathString.split(path.sep).join("/")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export class ReleaseValidator {
|
||||
constructor(private updateOnlyUnreleased: boolean) {
|
||||
}
|
||||
constructor(private updateOnlyUnreleased: boolean) {}
|
||||
|
||||
validateReleaseUpdate(releaseResponse: ReleaseStageArguments) {
|
||||
if (!this.updateOnlyUnreleased) {
|
||||
@@ -8,7 +7,9 @@ export class ReleaseValidator {
|
||||
}
|
||||
|
||||
if (!releaseResponse.draft && !releaseResponse.prerelease) {
|
||||
throw new Error(`Tried to update "${releaseResponse.name ?? "release"}" which is neither a draft or prerelease. (updateOnlyUnreleased is on)`)
|
||||
throw new Error(
|
||||
`Tried to update "${releaseResponse.name ?? "release"}" which is neither a draft or prerelease. (updateOnlyUnreleased is on)`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,4 +18,4 @@ export type ReleaseStageArguments = {
|
||||
draft: boolean
|
||||
name: string | null
|
||||
prerelease: boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {GitHub} from '@actions/github/lib/utils'
|
||||
import {OctokitResponse} from "@octokit/types";
|
||||
import {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods";
|
||||
import {Inputs} from "./Inputs";
|
||||
import type { GitHub } from "@actions/github/lib/utils"
|
||||
import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"
|
||||
import type { OctokitResponse } from "@octokit/types"
|
||||
import type { Inputs } from "./Inputs"
|
||||
|
||||
export type CreateReleaseResponse = RestEndpointMethodTypes["repos"]["createRelease"]["response"]
|
||||
export type ReleaseByTagResponse = RestEndpointMethodTypes["repos"]["getReleaseByTag"]["response"]
|
||||
@@ -10,11 +10,14 @@ export type ListReleaseAssetsResponseData = RestEndpointMethodTypes["repos"]["li
|
||||
export type UpdateReleaseResponse = RestEndpointMethodTypes["repos"]["updateRelease"]["response"]
|
||||
export type UploadArtifactResponse = RestEndpointMethodTypes["repos"]["uploadReleaseAsset"]["response"]
|
||||
export type CreateOrUpdateReleaseResponse = CreateReleaseResponse | UpdateReleaseResponse
|
||||
export type GenerateReleaseNotesResponse = RestEndpointMethodTypes["repos"]["generateReleaseNotes"]["response"]
|
||||
|
||||
export type ReleaseData = {
|
||||
id: number
|
||||
html_url: string
|
||||
upload_url: string
|
||||
tarball_url: string | null
|
||||
zipball_url: string | null
|
||||
}
|
||||
|
||||
export interface Releases {
|
||||
@@ -25,7 +28,7 @@ export interface Releases {
|
||||
discussionCategory?: string,
|
||||
draft?: boolean,
|
||||
generateReleaseNotes?: boolean,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
name?: string,
|
||||
prerelease?: boolean
|
||||
): Promise<CreateReleaseResponse>
|
||||
@@ -34,6 +37,8 @@ export interface Releases {
|
||||
|
||||
getByTag(tag: string): Promise<ReleaseByTagResponse>
|
||||
|
||||
generateReleaseNotes(tag: string): Promise<GenerateReleaseNotesResponse>
|
||||
|
||||
listArtifactsForRelease(releaseId: number): Promise<ListReleaseAssetsResponseData>
|
||||
|
||||
listReleases(): Promise<ListReleasesResponse>
|
||||
@@ -45,7 +50,7 @@ export interface Releases {
|
||||
commitHash?: string,
|
||||
discussionCategory?: string,
|
||||
draft?: boolean,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
name?: string,
|
||||
prerelease?: boolean
|
||||
): Promise<UpdateReleaseResponse>
|
||||
@@ -56,7 +61,7 @@ export interface Releases {
|
||||
contentType: string,
|
||||
file: string | object,
|
||||
name: string,
|
||||
releaseId: number,
|
||||
releaseId: number
|
||||
): Promise<UploadArtifactResponse>
|
||||
}
|
||||
|
||||
@@ -76,7 +81,7 @@ export class GithubReleases implements Releases {
|
||||
discussionCategory?: string,
|
||||
draft?: boolean,
|
||||
generateReleaseNotes?: boolean,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
name?: string,
|
||||
prerelease?: boolean
|
||||
): Promise<CreateReleaseResponse> {
|
||||
@@ -92,17 +97,23 @@ export class GithubReleases implements Releases {
|
||||
prerelease: prerelease,
|
||||
repo: this.inputs.repo,
|
||||
target_commitish: commitHash,
|
||||
tag_name: tag
|
||||
tag_name: tag,
|
||||
})
|
||||
}
|
||||
|
||||
async deleteArtifact(
|
||||
assetId: number
|
||||
): Promise<OctokitResponse<any>> {
|
||||
async deleteArtifact(assetId: number): Promise<OctokitResponse<any>> {
|
||||
return this.git.rest.repos.deleteReleaseAsset({
|
||||
asset_id: assetId,
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
})
|
||||
}
|
||||
|
||||
async generateReleaseNotes(tag: string): Promise<GenerateReleaseNotesResponse> {
|
||||
return this.git.rest.repos.generateReleaseNotes({
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo,
|
||||
tag_name: tag,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -110,24 +121,22 @@ export class GithubReleases implements Releases {
|
||||
return this.git.rest.repos.getReleaseByTag({
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo,
|
||||
tag: tag
|
||||
tag: tag,
|
||||
})
|
||||
}
|
||||
|
||||
async listArtifactsForRelease(
|
||||
releaseId: number
|
||||
): Promise<ListReleaseAssetsResponseData> {
|
||||
async listArtifactsForRelease(releaseId: number): Promise<ListReleaseAssetsResponseData> {
|
||||
return this.git.paginate(this.git.rest.repos.listReleaseAssets, {
|
||||
owner: this.inputs.owner,
|
||||
release_id: releaseId,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
})
|
||||
}
|
||||
|
||||
async listReleases(): Promise<ListReleasesResponse> {
|
||||
return this.git.rest.repos.listReleases({
|
||||
owner: this.inputs.owner,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -138,7 +147,7 @@ export class GithubReleases implements Releases {
|
||||
commitHash?: string,
|
||||
discussionCategory?: string,
|
||||
draft?: boolean,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
makeLatest?: "legacy" | "true" | "false" | undefined,
|
||||
name?: string,
|
||||
prerelease?: boolean
|
||||
): Promise<UpdateReleaseResponse> {
|
||||
@@ -154,7 +163,7 @@ export class GithubReleases implements Releases {
|
||||
prerelease: prerelease,
|
||||
repo: this.inputs.repo,
|
||||
target_commitish: commitHash,
|
||||
tag_name: tag
|
||||
tag_name: tag,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -164,19 +173,19 @@ export class GithubReleases implements Releases {
|
||||
contentType: string,
|
||||
file: string | object,
|
||||
name: string,
|
||||
releaseId: number,
|
||||
releaseId: number
|
||||
): Promise<UploadArtifactResponse> {
|
||||
return this.git.rest.repos.uploadReleaseAsset({
|
||||
url: assetUrl,
|
||||
headers: {
|
||||
"content-length": contentLength,
|
||||
"content-type": contentType
|
||||
"content-type": contentType,
|
||||
},
|
||||
data: file as any,
|
||||
name: name,
|
||||
owner: this.inputs.owner,
|
||||
release_id: releaseId,
|
||||
repo: this.inputs.repo
|
||||
repo: this.inputs.repo,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./lib",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
|
||||
219
yarn.lock
219
yarn.lock
@@ -17,15 +17,18 @@
|
||||
dependencies:
|
||||
"@actions/io" "^1.0.1"
|
||||
|
||||
"@actions/github@^6.0.0":
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-6.0.0.tgz#65883433f9d81521b782a64cc1fd45eef2191ea7"
|
||||
integrity sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==
|
||||
"@actions/github@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-6.0.1.tgz#76e5f96df062c90635a7181ef45ff1c4ac21306e"
|
||||
integrity sha512-xbZVcaqD4XnQAe35qSQqskb3SqIAfRyLBrHMd/8TuL7hJSz2QtbDwnNM8zWx4zO5l2fnGtseNE3MbEvD7BxVMw==
|
||||
dependencies:
|
||||
"@actions/http-client" "^2.2.0"
|
||||
"@octokit/core" "^5.0.1"
|
||||
"@octokit/plugin-paginate-rest" "^9.0.0"
|
||||
"@octokit/plugin-rest-endpoint-methods" "^10.0.0"
|
||||
"@octokit/plugin-paginate-rest" "^9.2.2"
|
||||
"@octokit/plugin-rest-endpoint-methods" "^10.4.0"
|
||||
"@octokit/request" "^8.4.1"
|
||||
"@octokit/request-error" "^5.1.1"
|
||||
undici "^5.28.5"
|
||||
|
||||
"@actions/http-client@^2.0.1", "@actions/http-client@^2.2.0":
|
||||
version "2.2.0"
|
||||
@@ -571,6 +574,60 @@
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@biomejs/biome@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/biome/-/biome-1.9.4.tgz#89766281cbc3a0aae865a7ff13d6aaffea2842bf"
|
||||
integrity sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==
|
||||
optionalDependencies:
|
||||
"@biomejs/cli-darwin-arm64" "1.9.4"
|
||||
"@biomejs/cli-darwin-x64" "1.9.4"
|
||||
"@biomejs/cli-linux-arm64" "1.9.4"
|
||||
"@biomejs/cli-linux-arm64-musl" "1.9.4"
|
||||
"@biomejs/cli-linux-x64" "1.9.4"
|
||||
"@biomejs/cli-linux-x64-musl" "1.9.4"
|
||||
"@biomejs/cli-win32-arm64" "1.9.4"
|
||||
"@biomejs/cli-win32-x64" "1.9.4"
|
||||
|
||||
"@biomejs/cli-darwin-arm64@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz#dfa376d23a54a2d8f17133c92f23c1bf2e62509f"
|
||||
integrity sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==
|
||||
|
||||
"@biomejs/cli-darwin-x64@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz#eafc2ce3849d385fc02238aad1ca4a73395a64d9"
|
||||
integrity sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==
|
||||
|
||||
"@biomejs/cli-linux-arm64-musl@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz#d780c3e01758fc90f3268357e3f19163d1f84fca"
|
||||
integrity sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==
|
||||
|
||||
"@biomejs/cli-linux-arm64@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz#8ed1dd0e89419a4b66a47f95aefb8c46ae6041c9"
|
||||
integrity sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==
|
||||
|
||||
"@biomejs/cli-linux-x64-musl@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz#f36982b966bd671a36671e1de4417963d7db15fb"
|
||||
integrity sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==
|
||||
|
||||
"@biomejs/cli-linux-x64@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz#a0a7f56680c76b8034ddc149dbf398bdd3a462e8"
|
||||
integrity sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==
|
||||
|
||||
"@biomejs/cli-win32-arm64@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz#e2ef4e0084e76b7e26f0fc887c5ef1265ea56200"
|
||||
integrity sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==
|
||||
|
||||
"@biomejs/cli-win32-x64@1.9.4":
|
||||
version "1.9.4"
|
||||
resolved "https://registry.yarnpkg.com/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz#4c7afa90e3970213599b4095e62f87e5972b2340"
|
||||
integrity sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==
|
||||
|
||||
"@fastify/busboy@^2.0.0":
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.0.tgz#0709e9f4cb252351c609c6e6d8d6779a8d25edff"
|
||||
@@ -904,12 +961,12 @@
|
||||
before-after-hook "^2.2.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/endpoint@^9.0.0":
|
||||
version "9.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.4.tgz#8afda5ad1ffc3073d08f2b450964c610b821d1ea"
|
||||
integrity sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==
|
||||
"@octokit/endpoint@^9.0.6":
|
||||
version "9.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.6.tgz#114d912108fe692d8b139cfe7fc0846dfd11b6c0"
|
||||
integrity sha512-H1fNTMA57HbkFESSt3Y9+FBICv+0jFceJFPWDePYlR/iMGrwM5ph+Dd4XRQs+8X+PUFURLQgX9ChPfhJ/1uNQw==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.0.0"
|
||||
"@octokit/types" "^13.1.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/graphql@^7.0.0":
|
||||
@@ -926,46 +983,70 @@
|
||||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-19.1.0.tgz#75ec7e64743870fc73e1ab4bc6ec252ecdd624dc"
|
||||
integrity sha512-6G+ywGClliGQwRsjvqVYpklIfa7oRPA0vyhPQG/1Feh+B+wU0vGH1JiJ5T25d3g1JZYBHzR2qefLi9x8Gt+cpw==
|
||||
|
||||
"@octokit/plugin-paginate-rest@^9.0.0":
|
||||
version "9.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.5.tgz#1705bcef4dcde1f4015ee58a63dc61b68648f480"
|
||||
integrity sha512-WKTQXxK+bu49qzwv4qKbMMRXej1DU2gq017euWyKVudA6MldaSSQuxtz+vGbhxV4CjxpUxjZu6rM2wfc1FiWVg==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.4.0"
|
||||
"@octokit/openapi-types@^20.0.0":
|
||||
version "20.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-20.0.0.tgz#9ec2daa0090eeb865ee147636e0c00f73790c6e5"
|
||||
integrity sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA==
|
||||
|
||||
"@octokit/plugin-rest-endpoint-methods@^10.0.0":
|
||||
version "10.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.2.0.tgz#eeaa4de97a2ae26404dea30ce3e17b11928e027c"
|
||||
integrity sha512-ePbgBMYtGoRNXDyKGvr9cyHjQ163PbwD0y1MkDJCpkO2YH4OeXX40c4wYHKikHGZcpGPbcRLuy0unPUuafco8Q==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.3.0"
|
||||
"@octokit/openapi-types@^23.0.1":
|
||||
version "23.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-23.0.1.tgz#3721646ecd36b596ddb12650e0e89d3ebb2dd50e"
|
||||
integrity sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==
|
||||
|
||||
"@octokit/request-error@^5.0.0":
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.0.1.tgz#277e3ce3b540b41525e07ba24c5ef5e868a72db9"
|
||||
integrity sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==
|
||||
"@octokit/plugin-paginate-rest@^9.2.2":
|
||||
version "9.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.2.tgz#c516bc498736bcdaa9095b9a1d10d9d0501ae831"
|
||||
integrity sha512-u3KYkGF7GcZnSD/3UP0S7K5XUFT2FkOQdcfXZGZQPGv3lm4F2Xbf71lvjldr8c1H3nNbF+33cLEkWYbokGWqiQ==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.0.0"
|
||||
"@octokit/types" "^12.6.0"
|
||||
|
||||
"@octokit/plugin-rest-endpoint-methods@^10.4.0":
|
||||
version "10.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz#41ba478a558b9f554793075b2e20cd2ef973be17"
|
||||
integrity sha512-xV1b+ceKV9KytQe3zCVqjg+8GTGfDYwaT1ATU5isiUyVtlVAO3HNdzpS4sr4GBx4hxQ46s7ITtZrAsxG22+rVg==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.6.0"
|
||||
|
||||
"@octokit/request-error@^5.0.0", "@octokit/request-error@^5.1.1":
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.1.1.tgz#b9218f9c1166e68bb4d0c89b638edc62c9334805"
|
||||
integrity sha512-v9iyEQJH6ZntoENr9/yXxjuezh4My67CBSu9r6Ve/05Iu5gNgnisNWOsoJHTP6k0Rr0+HQIpnH+kyammu90q/g==
|
||||
dependencies:
|
||||
"@octokit/types" "^13.1.0"
|
||||
deprecation "^2.0.0"
|
||||
once "^1.4.0"
|
||||
|
||||
"@octokit/request@^8.0.1", "@octokit/request@^8.0.2":
|
||||
version "8.1.6"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-8.1.6.tgz#a76a859c30421737a3918b40973c2ff369009571"
|
||||
integrity sha512-YhPaGml3ncZC1NfXpP3WZ7iliL1ap6tLkAp6MvbK2fTTPytzVUyUesBBogcdMm86uRYO5rHaM1xIWxigWZ17MQ==
|
||||
"@octokit/request@^8.0.1", "@octokit/request@^8.0.2", "@octokit/request@^8.4.1":
|
||||
version "8.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-8.4.1.tgz#715a015ccf993087977ea4365c44791fc4572486"
|
||||
integrity sha512-qnB2+SY3hkCmBxZsR/MPCybNmbJe4KAlfWErXq+rBKkQJlbjdJeS85VI9r8UqeLYLvnAenU8Q1okM/0MBsAGXw==
|
||||
dependencies:
|
||||
"@octokit/endpoint" "^9.0.0"
|
||||
"@octokit/request-error" "^5.0.0"
|
||||
"@octokit/types" "^12.0.0"
|
||||
"@octokit/endpoint" "^9.0.6"
|
||||
"@octokit/request-error" "^5.1.1"
|
||||
"@octokit/types" "^13.1.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/types@^12.0.0", "@octokit/types@^12.3.0", "@octokit/types@^12.4.0":
|
||||
"@octokit/types@^12.0.0":
|
||||
version "12.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-12.4.0.tgz#8f97b601e91ce6b9776ed8152217e77a71be7aac"
|
||||
integrity sha512-FLWs/AvZllw/AGVs+nJ+ELCDZZJk+kY0zMen118xhL2zD0s1etIUHm1odgjP7epxYU1ln7SZxEUWYop5bhsdgQ==
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^19.1.0"
|
||||
|
||||
"@octokit/types@^12.6.0":
|
||||
version "12.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-12.6.0.tgz#8100fb9eeedfe083aae66473bd97b15b62aedcb2"
|
||||
integrity sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^20.0.0"
|
||||
|
||||
"@octokit/types@^13.1.0":
|
||||
version "13.8.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-13.8.0.tgz#3815885e5abd16ed9ffeea3dced31d37ce3f8a0a"
|
||||
integrity sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^23.0.1"
|
||||
|
||||
"@pkgjs/parseargs@^0.11.0":
|
||||
version "0.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
|
||||
@@ -1057,12 +1138,12 @@
|
||||
expect "^29.0.0"
|
||||
pretty-format "^29.0.0"
|
||||
|
||||
"@types/node@*", "@types/node@^22.10.3":
|
||||
version "22.10.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.3.tgz#cdc2a89bf6e5d5e593fad08e83f74d7348d5dd10"
|
||||
integrity sha512-DifAyw4BkrufCILvD3ucnuN8eydUfc/C1GlyrnI+LK6543w5/L3VeVgf05o3B4fqSXP1dKYLOZsKfutpxPzZrw==
|
||||
"@types/node@*", "@types/node@^22.15.29":
|
||||
version "22.15.29"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.15.29.tgz#c75999124a8224a3f79dd8b6ccfb37d74098f678"
|
||||
integrity sha512-LNdjOkUDlU1RZb8e1kOIUpN1qQUlzGkEtbVNo53vbrwDg5om6oduhm4SiUaPW5ASTXhAiP0jInWG8Qx9fVlOeQ==
|
||||
dependencies:
|
||||
undici-types "~6.20.0"
|
||||
undici-types "~6.21.0"
|
||||
|
||||
"@types/stack-utils@^2.0.0":
|
||||
version "2.0.0"
|
||||
@@ -1626,10 +1707,10 @@ get-stream@^6.0.0:
|
||||
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7"
|
||||
integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==
|
||||
|
||||
glob@^11.0.0:
|
||||
version "11.0.0"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.0.tgz#6031df0d7b65eaa1ccb9b29b5ced16cea658e77e"
|
||||
integrity sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==
|
||||
glob@^11.0.2:
|
||||
version "11.0.2"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.2.tgz#3261e3897bbc603030b041fd77ba636022d51ce0"
|
||||
integrity sha512-YT7U7Vye+t5fZ/QMkBFrTJ7ZQxInIUjwyAjVj84CYXqgBdv30MFUPGnBR6sQaVq6Is15wYJUsnzTuWaGRBhBAQ==
|
||||
dependencies:
|
||||
foreground-child "^3.1.0"
|
||||
jackspeak "^4.0.1"
|
||||
@@ -2532,10 +2613,10 @@ semver@^6.0.0, semver@^6.3.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
||||
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
||||
|
||||
semver@^7.5.3, semver@^7.5.4, semver@^7.6.3:
|
||||
version "7.6.3"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
|
||||
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
|
||||
semver@^7.5.3, semver@^7.5.4, semver@^7.7.2:
|
||||
version "7.7.2"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.2.tgz#67d99fdcd35cec21e6f8b87a7fd515a33f982b58"
|
||||
integrity sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==
|
||||
|
||||
shebang-command@^2.0.0:
|
||||
version "2.0.0"
|
||||
@@ -2738,10 +2819,10 @@ to-regex-range@^5.0.1:
|
||||
dependencies:
|
||||
is-number "^7.0.0"
|
||||
|
||||
ts-jest@^29.2.5:
|
||||
version "29.2.5"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.2.5.tgz#591a3c108e1f5ebd013d3152142cb5472b399d63"
|
||||
integrity sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==
|
||||
ts-jest@^29.3.4:
|
||||
version "29.3.4"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.3.4.tgz#9354472aceae1d3867a80e8e02014ea5901aee41"
|
||||
integrity sha512-Iqbrm8IXOmV+ggWHOTEbjwyCf2xZlUMv5npExksXohL+tk8va4Fjhb+X2+Rt9NBmgO7bJ8WpnMLOwih/DnMlFA==
|
||||
dependencies:
|
||||
bs-logger "^0.2.6"
|
||||
ejs "^3.1.10"
|
||||
@@ -2750,7 +2831,8 @@ ts-jest@^29.2.5:
|
||||
json5 "^2.2.3"
|
||||
lodash.memoize "^4.1.2"
|
||||
make-error "^1.3.6"
|
||||
semver "^7.6.3"
|
||||
semver "^7.7.2"
|
||||
type-fest "^4.41.0"
|
||||
yargs-parser "^21.1.1"
|
||||
|
||||
tunnel@^0.0.6:
|
||||
@@ -2768,20 +2850,25 @@ type-fest@^0.11.0:
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1"
|
||||
integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==
|
||||
|
||||
typescript@^5.7.3:
|
||||
version "5.7.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.3.tgz#919b44a7dbb8583a9b856d162be24a54bf80073e"
|
||||
integrity sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==
|
||||
type-fest@^4.41.0:
|
||||
version "4.41.0"
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.41.0.tgz#6ae1c8e5731273c2bf1f58ad39cbae2c91a46c58"
|
||||
integrity sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==
|
||||
|
||||
undici-types@~6.20.0:
|
||||
version "6.20.0"
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433"
|
||||
integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==
|
||||
typescript@^5.8.3:
|
||||
version "5.8.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
|
||||
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==
|
||||
|
||||
undici@^5.25.4:
|
||||
version "5.28.4"
|
||||
resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068"
|
||||
integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==
|
||||
undici-types@~6.21.0:
|
||||
version "6.21.0"
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb"
|
||||
integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==
|
||||
|
||||
undici@^5.25.4, undici@^5.28.5:
|
||||
version "5.29.0"
|
||||
resolved "https://registry.yarnpkg.com/undici/-/undici-5.29.0.tgz#419595449ae3f2cdcba3580a2e8903399bd1f5a3"
|
||||
integrity sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==
|
||||
dependencies:
|
||||
"@fastify/busboy" "^2.0.0"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user