Skip to content

Commit

Permalink
Transition autorest.v2 release pipelines to 1es-templates (#4932)
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd authored Mar 27, 2024
1 parent 3a8c0bf commit 6a1a091
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 54 deletions.
61 changes: 37 additions & 24 deletions .scripts/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,41 @@
trigger:
- v2

pool:
vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
npm install -g [email protected]
# npm install
npm install
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
# build packages
npm run publish-preview
# publish autorest core to a github release.
v=`dir src/autorest-core/*.tgz | sed 's/.*\(2\.0\..*\)\.tgz/\1/g'`
publish-release --token $(azuresdk-github-pat) --repo autorest --owner azure --name autorest-core-$v --tag autorest-core-$v --notes='v2 prerelease build' --prerelease --editRelease false --assets ./src/autorest-core/microsoft.azure-autorest-core-$v.tgz --target_commitish $(Build.SourceBranchName)
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
cd ..
extends:
template: /eng/pipelines/templates/1es-redirect.yml
parameters:
stages:
- stage: Publish_Stage
variables:
- template: /eng/pipelines/templates/variables/image.yml
jobs:
- job:
displayName: NPM Publishing

pool:
name: $(LINUXNEXTPOOL)
image: $(LINUXNEXTVMIMAGE)
os: linux

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
npm install -g [email protected]
# npm install
npm install
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
# build packages
npm run publish-preview
# publish autorest core to a github release.
v=`dir src/autorest-core/*.tgz | sed 's/.*\(2\.0\..*\)\.tgz/\1/g'`
publish-release --token $(azuresdk-github-pat) --repo autorest --owner azure --name autorest-core-$v --tag autorest-core-$v --notes='v2 prerelease build' --prerelease --editRelease false --assets ./src/autorest-core/microsoft.azure-autorest-core-$v.tgz --target_commitish $(Build.SourceBranchName)
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
cd ..
72 changes: 42 additions & 30 deletions .scripts/push-to-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,48 @@
# if you want to set a secondary tag on the package (like V2), set the $(altTag) variable

trigger:
- master
- v2

pool:
vmImage: "ubuntu-latest"
extends:
template: /eng/pipelines/templates/1es-redirect.yml
parameters:
stages:
- stage: Publish_Stage
jobs:
- job:
displayName: NPM Publishing

steps:
- task: NodeTool@0
inputs:
versionSpec: "12.x"
displayName: "Install Node.js"
pool:
name: $(LINUXNEXTPOOL)
image: $(LINUXNEXTVMIMAGE)
os: linux

- script: |
npm config set //registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)
# grab the file specified
wget $(pkg)
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
# determine the tag
npmTag="latest"
if [ -n "$(tag)" ]; then
npmTag=$(tag)
fi
# publish it to npm
for file in *.tgz
do
npm publish $file --tag $npmTag --access public
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
# set the alternate tag, if applicable
if [ -n "$(altTag)" ]; then
tar -zxvf $file
cd package/
npm dist-tag add $(npm show . name)@$(npm show . version) --tag $(altTag)
fi
done
steps:
- task: NodeTool@0
inputs:
versionSpec: "12.x"
displayName: "Install Node.js"

- script: |
npm config set //registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)
# grab the file specified
wget $(pkg)
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
# determine the tag
npmTag="latest"
if [ -n "$(tag)" ]; then
npmTag=$(tag)
fi
# publish it to npm
for file in *.tgz
do
npm publish $file --tag $npmTag --access public
rc=$?; if [ $rc -ne 0 ]; then exit $rc ; fi
# set the alternate tag, if applicable
if [ -n "$(altTag)" ]; then
tar -zxvf $file
cd package/
npm dist-tag add $(npm show . name)@$(npm show . version) --tag $(altTag)
fi
done
displayName: "Publish to NPM"
12 changes: 12 additions & 0 deletions eng/CredScanSuppression.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"tool": "Credential Scanner",
"suppressions": [
{
"placeholder": [
"#################",
"P@$$w0rd"
],
"_justification": "Secrets used by test code or documentation, they are fake."
}
]
}
60 changes: 60 additions & 0 deletions eng/pipelines/templates/1es-redirect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

parameters:
- name: stages
type: stageList
default: []
- name: variables
type: object
default: {}
- name: Use1ESOfficial
type: boolean
default: true

extends:
${{ if and(parameters.Use1ESOfficial, eq(variables['System.TeamProject'], 'internal')) }}:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
${{ else }}:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
settings:
skipBuildTagsForGitHubPullRequests: true
sdl:
git:
longpaths: true
sourceAnalysisPool:
name: azsdk-pool-mms-win-2022-general
image: azsdk-pool-mms-win-2022-1espt
os: windows
psscriptanalyzer:
compiled: true
break: true
credscan:
suppressionsFile: $(Build.SourcesDirectory)/eng/CredScanSuppression.json
eslint:
enabled: false
justificationForDisabling: "ESLint injected task has failures because it uses an old version of mkdirp. We should not fail for tools not controlled by the repo. See: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3556850"
stages:
- ${{ each stage in parameters.stages }}:
- ${{ each pair in stage }}:
${{ if ne(pair.key, 'variables') }}:
${{ pair.key }}: ${{ pair.value }}
variables:
- template: /eng/pipelines/templates/variables/image.yml@self
- ${{ each variable in parameters.variables }}:
- ${{ if eq(variable.key, 'template') }}:
- template: ${{ variable.value }}
- ${{ else }}:
- name: ${{ coalesce(variable.key, variable.name) }}
value: ${{ variable.value }}
- ${{ each variable in stage.variables }}:
- ${{ if in(variable.key, 'template', 'group') }}:
- ${{ variable.key }}: ${{ variable.value }}
- ${{ else }}:
- name: ${{ coalesce(variable.key, variable.name) }}
value: ${{ variable.value }}
26 changes: 26 additions & 0 deletions eng/pipelines/templates/variables/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
variables:
- name: LINUXPOOL
value: azsdk-pool-mms-ubuntu-2004-general
- name: LINUXNEXTPOOL
value: azsdk-pool-mms-ubuntu-2204-general
- name: WINDOWSPOOL
value: azsdk-pool-mms-win-2022-general
- name: MACPOOL
value: Azure Pipelines

- name: LINUXVMIMAGE
value: azsdk-pool-mms-ubuntu-2004-1espt
- name: LINUXNEXTVMIMAGE
value: azsdk-pool-mms-ubuntu-2204-1espt
- name: WINDOWSVMIMAGE
value: azsdk-pool-mms-win-2022-1espt
- name: MACVMIMAGE
value: macos-11

# Values required for pool.os field in 1es pipeline templates
- name: LINUXOS
value: linux
- name: WINDOWSOS
value: windows
- name: MACOS
value: macOS

0 comments on commit 6a1a091

Please sign in to comment.