Skip to content

Commit 5f790eb

Browse files
authored
Auto-trigger release pipeline on main merge and add version check (#3335)
* Auto-trigger release pipeline on main merge and add version check * Simplify trigger syntax in publish-release.yml
1 parent 57395b5 commit 5f790eb

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pnpm clean
3737
**Semi-auto:**
3838

3939
Follow https://github.com/Azure/autorest.python/blob/main/.github/skills/bump-and-release/SKILL.md to make a release PR.
40-
After it merged, trigger [release pipeline](https://dev.azure.com/azure-sdk/internal/_build?definitionId=1668) to release new version.
40+
After it merged, [release pipeline](https://dev.azure.com/azure-sdk/internal/_build?definitionId=1668) will be triggered automatically to release new version.
4141

4242
## Contributing
4343

eng/pipelines/publish-release.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# This is a manual pipeline, don't trigger automatically
2-
trigger: none
1+
# Trigger only after PR merged into main
2+
trigger:
3+
- main
34
pr: none
45

56
extends:
@@ -28,6 +29,31 @@ extends:
2829
inputs:
2930
versionSpec: 3.10
3031

32+
- script: |
33+
set -e
34+
35+
# Check @azure-tools/typespec-python
36+
TYPESPEC_VERSION=$(node -p "require('./packages/typespec-python/package.json').version")
37+
echo "Checking if @azure-tools/typespec-python@$TYPESPEC_VERSION is already published..."
38+
if npm view @azure-tools/typespec-python@$TYPESPEC_VERSION version 2>/dev/null; then
39+
echo "##vso[task.logissue type=error]@azure-tools/typespec-python@$TYPESPEC_VERSION is already published to npm"
40+
exit 1
41+
fi
42+
echo "@azure-tools/typespec-python@$TYPESPEC_VERSION is not yet published"
43+
44+
# Check @autorest/python
45+
AUTOREST_VERSION=$(node -p "require('./packages/autorest.python/package.json').version")
46+
echo "Checking if @autorest/python@$AUTOREST_VERSION is already published..."
47+
if npm view @autorest/python@$AUTOREST_VERSION version 2>/dev/null; then
48+
echo "##vso[task.logissue type=error]@autorest/python@$AUTOREST_VERSION is already published to npm"
49+
exit 1
50+
fi
51+
echo "@autorest/python@$AUTOREST_VERSION is not yet published"
52+
53+
echo "Version check passed. Proceeding with build and tests."
54+
displayName: Check if versions are already published
55+
workingDirectory: $(Build.SourcesDirectory)
56+
3157
- script: npm install -g pnpm@9.5.0
3258
displayName: Install PNPM 9.5.0
3359

0 commit comments

Comments
 (0)