fix #729: Remove archive after extraction (#792)

* fix #729: Remove archive after extraction

Almost all uses of this action that will be extracting a release archive will not need the archive after the fact, so I opted to not put this behind a flag option.

* Move extraction info log after file removal

* Remove unwanted async from rm, fix tests

---------

Co-authored-by: Robin Raju <robinraju@users.noreply.github.com>
This commit is contained in:
Wires77andRobin Raju authored and GitHub committed 2026-04-18 16:02:19 +01:00
1 parent ffd8c6699a
commit 3bd996fb72
2 files changed
+11 -1

No files matched your search

+3 -1
View File
@@ -36,8 +36,10 @@ describe('extract', () => {
test('extracts a tar.gz archive into a created destination directory', async () => {
const destination = path.join(testRoot, 'tar-gz-output')
const archivePath = path.join(testRoot, 'tar-zip-ball-only-repo.tar.gz')
fs.copyFileSync(fixturePath('tar-zip-ball-only-repo.tar.gz'), archivePath)
await extract(fixturePath('tar-zip-ball-only-repo.tar.gz'), destination)
await extract(archivePath, destination)
expect(fs.existsSync(destination)).toBe(true)
expect(fs.readdirSync(destination).length).toBeGreaterThan(0)
+8
View File
@@ -50,6 +50,14 @@ export const extract = async (
await zip.extract(null, destDir)
await zip.close()
}
fs.rm(filePath, err => {
if (err) {
core.warning(
`Failed to delete archive ${filename} after extraction: ${err.message}`
)
}
})
core.info(`Extracted ${filename} to ${destDir}`)
} catch (err) {
// Provide context for extraction failures