Skip to content

New GitHubReleaseAsset

Howard Wolosky edited this page Oct 5, 2020 · 1 revision

New-GitHubReleaseAsset

SYNOPSIS

Uploads a new asset for a release on GitHub.

SYNTAX

Elements

New-GitHubReleaseAsset [-OwnerName <String>] [-RepositoryName <String>] [-Release] <Int64> -Path <String>
 [-Label <String>] [-ContentType <String>] [-AccessToken <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

UploadUrl

New-GitHubReleaseAsset [-Uri <String>] [[-Release] <Int64>] [-UploadUrl] <String> -Path <String>
 [-Label <String>] [-ContentType <String>] [-AccessToken <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

Uri

New-GitHubReleaseAsset -Uri <String> [-Release] <Int64> -Path <String> [-Label <String>]
 [-ContentType <String>] [-AccessToken <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Uploads a new asset for a release on GitHub.

The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub

EXAMPLES

EXAMPLE 1

New-GitHubReleaseAsset -OwnerName microsoft -RepositoryName PowerShellForGitHub -Release 123456 -Path 'c:\foo.zip'

Uploads the file located at 'c:\foo.zip' to the 123456 release in microsoft/PowerShellForGitHub

EXAMPLE 2

$release = New-GitHubRelease -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag 'stable'
$release | New-GitHubReleaseAsset -Path 'c:\bar.txt'

Creates a new release tagged as 'stable' and then uploads 'c:\bar.txt' as an asset for that release.

PARAMETERS

-AccessToken

If provided, this will be used as the AccessToken for authentication with the REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ContentType

The MIME Media Type for the file being uploaded. By default, this will be inferred based on the file's extension. If the extension is not known by this module, it will fallback to using text/plain. You may specify a ContentType here to override the module's logic.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Label

An alternate short description of the asset. Used in place of the filename.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-OwnerName

Owner of the repository. If not supplied here, the DefaultOwnerName configuration property value will be used.

Type: System.String
Parameter Sets: Elements
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Path

The path to the file to upload as a new asset.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Release

The ID of the release that the asset is for.

Type: System.Int64
Parameter Sets: Elements, Uri
Aliases: ReleaseId

Required: True
Position: 2
Default value: 0
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Type: System.Int64
Parameter Sets: UploadUrl
Aliases: ReleaseId

Required: False
Position: 2
Default value: 0
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-RepositoryName

Name of the repository. If not supplied here, the DefaultRepositoryName configuration property value will be used.

Type: System.String
Parameter Sets: Elements
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UploadUrl

The value of 'upload_url' from getting the asset details.

Type: System.String
Parameter Sets: UploadUrl
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Uri

Uri for the repository. The OwnerName and RepositoryName will be extracted from here instead of needing to provide them individually.

Type: System.String
Parameter Sets: UploadUrl
Aliases: RepositoryUrl

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Type: System.String
Parameter Sets: Uri
Aliases: RepositoryUrl

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

GitHub.Branch

GitHub.Content

GitHub.Event

GitHub.Issue

GitHub.IssueComment

GitHub.Label

GitHub.Milestone

GitHub.PullRequest

GitHub.Project

GitHub.ProjectCard

GitHub.ProjectColumn

GitHub.Release

GitHub.ReleaseAsset

GitHub.Repository

OUTPUTS

GitHub.ReleaseAsset

NOTES

GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. Get-GitHubReleaseAsset lists the renamed filenames.

If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.

RELATED LINKS

PowerShellForGitHub

Docs

PowerShellForGitHub

Functions

Clone this wiki locally