Skip to content

Commit

Permalink
Refactor package release into one pipeline (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
weshaggard authored Jul 17, 2024
1 parent 26074ce commit 107162a
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 173 deletions.
23 changes: 0 additions & 23 deletions eng/pipelines/publish-dev-release-go.yml

This file was deleted.

23 changes: 0 additions & 23 deletions eng/pipelines/publish-dev-release-typespec.yml

This file was deleted.

50 changes: 0 additions & 50 deletions eng/pipelines/publish-release-go.yml

This file was deleted.

27 changes: 0 additions & 27 deletions eng/pipelines/publish-release-gotest.yml

This file was deleted.

50 changes: 0 additions & 50 deletions eng/pipelines/publish-release-typespec.yml

This file was deleted.

69 changes: 69 additions & 0 deletions eng/pipelines/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
trigger: none
pr: none

parameters:
- name: publish_dev
displayName: 'Publish Dev Release only'
type: boolean
default: true
- name: release_autorestgo
displayName: '@autorest/go'
type: boolean
default: false
- name: release_autorestgotest
displayName: '@autorest/gotest'
type: boolean
default: false
- name: release_typespecgo
displayName: '@azure-tools/typespec-go'
type: boolean
default: false

extends:
template: /eng/pipelines/templates/stages/1es-redirect.yml
parameters:
stages:
- stage: Release

variables:
- template: /eng/pipelines/templates/variables/image.yml

jobs:
- job: Release
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
os: linux

steps:
- template: /eng/pipelines/templates/steps/set-env.yaml

- ${{ if eq(parameters.release_autorestgo, true) }}:
- template: /eng/pipelines/templates/steps/build-test-go.yaml
- template: /eng/pipelines/templates/steps/publish-release.yaml
parameters:
PackagePath: "autorest.go"
PackageFileName: "autorest-go"
ReleaseName: "Autorest for Go v$currentVersion"
ReleaseNotes: "Autorest for Go track 2"
PublishDevVersion: ${{ parameters.publish_dev }}

- ${{ if eq(parameters.release_autorestgotest, true) }}:
- template: /eng/pipelines/templates/steps/build-test-gotest.yaml
- template: /eng/pipelines/templates/steps/publish-release.yaml
parameters:
PackagePath: "autorest.gotest"
PackageFileName: "autorest-gotest"
ReleaseName: "@autorest/gotest_v$currentVersion"
ReleaseNotes: "Go test generation"
PublishDevVersion: ${{ parameters.publish_dev }}

- ${{ if eq(parameters.release_typespecgo, true) }}:
- template: /eng/pipelines/templates/steps/build-test-typespec.yaml
- template: /eng/pipelines/templates/steps/publish-release.yaml
parameters:
PackagePath: "typespec-go"
PackageFileName: "azure-tools-typespec-go"
ReleaseName: "TypeSpec emitter for Go SDKs v$currentVersion"
ReleaseNotes: "TypeSpec emitter for Go SDKs"
PublishDevVersion: ${{ parameters.publish_dev }}
41 changes: 41 additions & 0 deletions eng/pipelines/templates/steps/publish-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
parameters:
PackagePath: "not-specified"
PackageFileName: "not-specfied"
ReleaseName: "not-specified"
ReleaseNotes: "not-specfied"
PublishDevVersion: true

steps:
- pwsh: |
$currentVersion = node -p -e "require('./packages/${{ parameters.PackagePath }}/package.json').version"
$releaseNotes = "${{ parameters.ReleaseNotes }}"
if ('${{ parameters.PublishDevVersion }}' -eq 'true') {
$currentVersion="$currentVersion-$(Build.BuildNumber)"
$releaseNotes = "Preview version of ${{ parameters.ReleaseNotes }}"
}
cd packages/${{ parameters.PackagePath }}
npm version --no-git-tag-version $currentVersion
npm pack
npm install -g ${{ parameters.PackageFileName }}-$currentVersion.tgz
if ($LASTEXITCODE) {
exit $LASTEXITCODE
}
npx publish-release `
--token $(azuresdk-github-pat) `
--repo autorest.go `
--owner azure `
--name "${{ parameters.ReleaseName }}" `
--tag v$currentVersion `
--notes="$releaseNotes" `
--prerelease `
--editRelease false `
--assets ${{ parameters.PackageFileName }}-$currentVersion.tgz `
--target_commitish $(Build.SourceBranchName);
displayName: "Publish GitHub Release ${{ parameters.PackagePath }}"
- ${{ if ne(parameters.PublishDevVersion, true) }}:
- script: |
cd packages/${{ parameters.PackagePath }}
echo "//registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)" > ./.npmrc
npm publish --access public
displayName: "Publish to npm ${{ parameters.PackagePath }}"

0 comments on commit 107162a

Please sign in to comment.