Skip to content

Commit

Permalink
Move publishing of containerhelper to federated credentials (#3545)
Browse files Browse the repository at this point in the history
Move publishing of containerhelper to federated credentials

Related to AB#535824
  • Loading branch information
aholstrup1 authored May 22, 2024
1 parent ebf71ec commit 4f9a821
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permissions:
actions: read
pull-requests: write
checks: write
id-token: write

concurrency:
group: 'runTests-${{ github.ref }}'
Expand Down Expand Up @@ -147,6 +148,20 @@ jobs:
needs: [ PS5, PS7, Linux ]
if: github.repository_owner == 'microsoft' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
steps:
- name: 'Az CLI login'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true

- name: Install Azure Powershell Modules
run: |
if(-not (Get-Module 'Az.Storage' -ListAvailable)) {
Install-Module -Name 'Az.Storage' -Force -AllowClobber
}
- name: Checkout
uses: actions/checkout@v4

Expand Down Expand Up @@ -216,17 +231,17 @@ jobs:
Set-AuthenticodeSignature -Certificate $cert -HashAlgorithm SHA256 -TimestampServer "http://timestamp.digicert.com" -FilePath $filesToSign
Write-Host "Upload to storage (preview)"
$storageContext = New-AzureStorageContext -ConnectionString '${{ secrets.BchStorageConnectionString }}'
New-AzureStorageContainer -Name 'public' -Context $storageContext -Permission 'Container' -ErrorAction Ignore | Out-Null
$storageContext = New-AzStorageContext -StorageAccountName 'bccontainerhelper' -UseConnectedAccount
New-AzStorageContainer -Name 'public' -Context $storageContext -Permission 'Container' -ErrorAction Ignore | Out-Null
Compress-Archive -path $path -DestinationPath "$($path).zip"
Set-AzureStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "$version-$prerelease.zip" -Force | Out-Null
Set-AzureStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "preview.zip" -Force | Out-Null
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "$version-$prerelease.zip" -Force | Out-Null
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "preview.zip" -Force | Out-Null
Write-Host "Publishing Module"
Publish-Module -Path $path -NuGetApiKey '${{ secrets.NugetKey }}' -SkipAutomaticTags
}
catch {
Write-Host "::Error::Error publishing module. Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}
}
25 changes: 20 additions & 5 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

permissions:
contents: read
id-token: write

concurrency: Release

Expand All @@ -17,6 +18,20 @@ jobs:
if: github.repository == 'Microsoft/NavContainerHelper'
runs-on: [ windows-latest ]
steps:
- name: 'Az CLI login'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true

- name: Install Azure Powershell Modules
run: |
if(-not (Get-Module 'Az.Storage' -ListAvailable)) {
Install-Module -Name 'Az.Storage' -Force -AllowClobber
}
- name: Checkout
uses: actions/checkout@v4

Expand Down Expand Up @@ -85,12 +100,12 @@ jobs:
Set-AuthenticodeSignature -Certificate $cert -HashAlgorithm SHA256 -TimestampServer "http://timestamp.digicert.com" -FilePath $filesToSign
Write-Host "Upload to storage (preview)"
$storageContext = New-AzureStorageContext -ConnectionString '${{ secrets.BchStorageConnectionString }}'
New-AzureStorageContainer -Name 'public' -Context $storageContext -Permission 'Container' -ErrorAction Ignore | Out-Null
$storageContext = New-AzStorageContext -StorageAccountName 'bccontainerhelper' -UseConnectedAccount
New-AzStorageContainer -Name 'public' -Context $storageContext -Permission 'Container' -ErrorAction Ignore | Out-Null
Compress-Archive -path $path -DestinationPath "$($path).zip"
Set-AzureStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "$version.zip" -Force | Out-Null
Set-AzureStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "latest.zip" -Force | Out-Null
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "$version.zip" -Force | Out-Null
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "latest.zip" -Force | Out-Null
Write-Host "Publishing Module"
Publish-Module -Path $path -NuGetApiKey '${{ secrets.NugetKey }}' -SkipAutomaticTags
Expand Down

0 comments on commit 4f9a821

Please sign in to comment.