Azure Site Extension #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Azure Site Extension | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: ["Create Release"] | |
types: | |
- completed | |
env: | |
SPEC_FILE_TEMPLATE: 'NewRelic.Azure.WebSites.Extension.NodeAgent.nuspec' | |
jobs: | |
create_extension_bundle: | |
runs-on: windows-latest | |
if: | |
(github.event.workflow_run && github.event.workflow_run.conclusion == 'success') || | |
(github.event_name == 'workflow_dispatch') | |
strategy: | |
matrix: | |
node-version: ['lts/*'] | |
arch: [ x64 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dotnet '6.0.x' | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
architecture: ${{ matrix.arch }} | |
- name: Get local agent version | |
run: | | |
$env:local_agent_version = node -p "require('./package.json').version" | |
echo "AGENT_VERSION=$env:local_agent_version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Find agent version at npm | |
run: | | |
$env:npm_agent_version = npm view newrelic version | |
echo "NPM_AGENT_VERSION=$env:npm_agent_version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Check NPM availability | |
if: ${{ env.NPM_AGENT_VERSION != env.AGENT_VERSION }} | |
run: | | |
$count = 0 | |
$seconds = 30 | |
while($count -lt 10) { | |
$seconds = ($seconds * $count) | |
echo "Sleeping $seconds ($count)" | |
Start-Sleep -s $seconds | |
$npmversion = npm view newrelic version | |
echo "Checking npm version ($count): $npmversion" | |
$test = [Version]$npmversion -match [Version]${{ env.AGENT_VERSION }} | |
if ([Version]$npmversion -match [Version]${{ env.AGENT_VERSION }}) { | |
break; | |
} | |
$count++ | |
} | |
$env:npm_agent_version = npm view newrelic version | |
echo "Done with delayed check. Published version: $env:npm_agent_version Local version: ${{env.AGENT_VERSION}}" | |
echo "NPM_AGENT_VERSION=$env:npm_agent_version" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Has the new agent been published? | |
if: ${{ env.NPM_AGENT_VERSION != env.AGENT_VERSION }} | |
run: | | |
echo "Published agent version (${{env.NPM_AGENT_VERSION }}) is behind local agent version (${{env.AGENT_VERSION}}); exiting." | |
exit 1; | |
- name: Set package filename | |
run: | | |
echo "PACKAGE_FILENAME=NewRelic.Azure.WebSites.Extension.NodeAgent.${{env.AGENT_VERSION}}" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Verify environment vars # because we can't access GH env vars until the next step | |
run: | | |
echo "Agent version: ${{ env.AGENT_VERSION }}" | |
echo "Package filename: ${{ env.PACKAGE_FILENAME }}" | |
- name: Install agent | |
working-directory: cloud-tooling/azure-site-extension/Content | |
run: | | |
npm i --prefix . newrelic@${{ env.AGENT_VERSION }} | |
echo "Agent installed" | |
- name: Configure package files | |
working-directory: cloud-tooling/azure-site-extension | |
run: | | |
(Get-Content ${{ env.SPEC_FILE_TEMPLATE }}).Replace('{VERSION}', "${{ env.AGENT_VERSION }}") | Set-Content ${{ env.PACKAGE_FILENAME }}.nuspec | |
- name: Create bundle | |
working-directory: cloud-tooling/azure-site-extension | |
run: nuget pack "${{ env.PACKAGE_FILENAME }}.nuspec" | |
# This step is for us to check what's going to be published | |
- name: Archive package for verification | |
uses: actions/upload-artifact@v4 | |
with: | |
name: azure-site-extension-test-${{ env.PACKAGE_FILENAME }} | |
path: cloud-tooling/azure-site-extension/${{ env.PACKAGE_FILENAME }}.nupkg | |
- name: Publish site extension | |
working-directory: cloud-tooling/azure-site-extension | |
run: | | |
dotnet nuget push "${{ env.PACKAGE_FILENAME }}.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source ${{ secrets.NUGET_SOURCE }} |