Skip to content

Commit

Permalink
Merge pull request #43 from nventive/dev/lebo/fix-publish-step
Browse files Browse the repository at this point in the history
fix: Fix CI authentication with pub.dev
  • Loading branch information
lesterbotello authored Aug 30, 2024
2 parents 75eb31c + a0ce2ed commit 0cbf860
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 35 deletions.
33 changes: 0 additions & 33 deletions src/cli/.azuredevops/stage-publish-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,6 @@ jobs:
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/cli'

- task: DownloadSecureFile@1
displayName: 'Download Google Cloud Key'
condition: succeeded()
inputs:
secureFile: 'flutter_publisher_gckey.json'
name: DownloadGCloudKey

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$zipUrl = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-windows-x86_64.zip"
$zipPath = "$(System.DefaultWorkingDirectory)\gcloud.zip"
$extractPath = "$(System.DefaultWorkingDirectory)\gcloud"
Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath
New-Item -ItemType Directory -Path $extractPath -Force
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
$gcloudPath = "$extractPath\google-cloud-sdk\bin\gcloud.cmd"
$gcloudDir = [System.IO.Path]::GetDirectoryName($gcloudPath)
# [System.Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";" + $gcloudDir, [System.EnvironmentVariableTarget]::Machine)
Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};$gcloudDir";
Write-Host "Updated PATH: $env:PATH"
Remove-Item -Path $zipPath -Force
displayName: 'Install Google Cloud SDK'

- template: templates/publish-package.yml
parameters:
pathToSrc: '${{ parameters.pathToSrc }}'
Expand Down
44 changes: 42 additions & 2 deletions src/cli/.azuredevops/templates/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,50 @@ steps:
inputs:
projectDirectory: '${{ parameters.pathToSrc }}/cli'
arguments: 'pub publish --dry-run'

- task: DownloadSecureFile@1
displayName: 'Download Google Cloud Key'
condition: succeeded()
inputs:
secureFile: 'flutter_publisher_gckey.json'
name: DownloadGCloudKey

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$zipUrl = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-windows-x86_64.zip"
$zipPath = "$(System.DefaultWorkingDirectory)\gcloud.zip"
$extractPath = "$(System.DefaultWorkingDirectory)\gcloud"
Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath
New-Item -ItemType Directory -Path $extractPath -Force
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
$gcloudPath = "$extractPath\google-cloud-sdk\bin\gcloud.cmd"
$gcloudDir = [System.IO.Path]::GetDirectoryName($gcloudPath)
# [System.Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";" + $gcloudDir, [System.EnvironmentVariableTarget]::Machine)
Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};$gcloudDir";
Write-Host "Updated PATH: $env:PATH"
Remove-Item -Path $zipPath -Force
displayName: 'Install Google Cloud SDK'

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
gcloud auth activate-service-account --key-file=$(DownloadGCloudKey.secureFilePath)
displayName: 'Activate service account'

- script: |
gcloud auth activate-service-account --key-file=$(DownloadGCloudKey.secureFilePath)
- script: |
gcloud auth print-identity-token --audiences=https://pub.dev | dart pub token add https://pub.dev
cd ${{ parameters.pathToSrc }}/cli
dart pub publish --force
condition: eq(${{ parameters.dryRun }}, false)
displayName: 'Flutter Pub Publish'
3 changes: 3 additions & 0 deletions src/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

Prefix your items with `(Template)` if the change is about the template and not the resulting application.

## 0.20.3
- (CI/CD) Fixes an authentication issue with pub.dev

## 0.20.2
- (Template) Fixes an issue with the CLI in which the build fails during template generation because of a missing required file.

Expand Down

0 comments on commit 0cbf860

Please sign in to comment.