Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .azure-pipelines/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Manual npm release publish pipeline for LogicAppsUX.
#
# Versioning and GitHub Release creation stay in .github/workflows/version-release.yml.
# Given a release version (e.g. 5.1024.0), this pipeline checks out the existing v<version>
# tag into a clean detached worktree, builds and packs the 9 publishable packages, and
# publishes any missing packages to the Azure Artifacts npm feed.
trigger: none
pr: none
schedules: []
name: ${{ coalesce(trim(parameters.releaseVersion), 'unversioned') }}-$(Date:yyyyMMdd)$(Rev:.r)

parameters:
- name: releaseVersion
displayName: Release version (e.g. 5.1024.0)
type: string
default: ''

variables:
NpmRegistry: 'https://pkgs.dev.azure.com/msazure/One/_packaging/microsoft-logic-apps/npm/registry/'
TarballDir: '$(Agent.TempDirectory)/npm-tarballs'
PublishNpmrc: '$(Agent.TempDirectory)/npm-publish/.npmrc'

resources:
repositories:
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
sdl:
componentgovernance:
useAgentBuildDirectory: true
sourceAnalysisPool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
stages:
- stage: Publish
displayName: Build and publish npm packages
lockBehavior: sequential
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/hotfix/v')))
jobs:
- job: BuildAndPublish
displayName: Build release tag and publish to npm feed
workspace:
clean: all
steps:
- checkout: self
clean: true
fetchTags: true
fetchDepth: 0
persistCredentials: false
- task: UseNode@1
displayName: Use Node 24
inputs:
version: '24.x'
- bash: node scripts/ado-npm-publisher.cjs build
displayName: Build and pack release packages
workingDirectory: '$(Build.Repository.LocalPath)'
env:
RELEASE_VERSION: ${{ parameters.releaseVersion }}
AGENT_TMP: '$(Agent.TempDirectory)'
RELEASE_SCAN_ROOT: '$(Agent.BuildDirectory)'
TARBALL_DIR: '$(TarballDir)'
NPM_REGISTRY: '$(NpmRegistry)'
PUBLISH_NPMRC: '$(PublishNpmrc)'
- task: npmAuthenticate@0
displayName: Authenticate npm feed via WIF
inputs:
workingFile: '$(PublishNpmrc)'
workloadIdentityServiceConnection: 21d5a1d8-11d3-425c-8d3a-e7f088725481
feedUrl: 'https://pkgs.dev.azure.com/msazure/One/_packaging/microsoft-logic-apps/npm/registry/'
- bash: node scripts/ado-npm-publisher.cjs publish
displayName: Publish packages to Azure Artifacts npm feed
workingDirectory: '$(Build.Repository.LocalPath)'
env:
RELEASE_VERSION: ${{ parameters.releaseVersion }}
TARBALL_DIR: '$(TarballDir)'
NPM_REGISTRY: '$(NpmRegistry)'
PUBLISH_NPMRC: '$(PublishNpmrc)'
108 changes: 101 additions & 7 deletions .github/workflows/version-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ jobs:
run: |
gh release upload ${{ needs.create-release.outputs.tag_name }} AgentChatIFrames-${IFRAME_VERSION}.zip --clobber

# NPM Publishing
# Iframe App Azure Blob Upload
- name: 'Azure login'
if: ${{ github.event.inputs.enable_blob_upload == 'true' }}
uses: azure/login@v3
with:
client-id: ${{ secrets.AZURE_TESTING_CLIENT_ID }}
Expand Down Expand Up @@ -292,12 +293,105 @@ jobs:

echo "Uploaded zip file and folder contents to container: $CONTAINER_NAME"

- name: 'Generate NPMRC'
publish-npm:
needs: create-release
runs-on: ubuntu-latest
environment: E2ETesting
permissions:
contents: read
steps:
- name: 'Trigger ADO npm publish via Otto'
shell: bash
env:
OTTO_WORKFLOW_URL: ${{ secrets.OTTO_NPM_PUBLISH_WORKFLOW_URL }}
RELEASE_VERSION: ${{ needs.create-release.outputs.new_version }}
TAG_NAME: ${{ needs.create-release.outputs.tag_name }}
SOURCE_BRANCH: ${{ github.ref }}
REPOSITORY: ${{ github.repository }}
GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
token=`az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 | jq -r .accessToken`
export ADO_TOKEN=$token
node ./productionNpmRCCreator.js
set -euo pipefail

# Fail fast if the Otto webhook URL secret is not configured.
if [[ -z "${OTTO_WORKFLOW_URL:-}" ]]; then
echo "::error::OTTO_NPM_PUBLISH_WORKFLOW_URL secret is not configured in environment E2ETesting."
exit 1
fi

PAYLOAD=$(jq -n \
--arg releaseVersion "$RELEASE_VERSION" \
--arg tagName "$TAG_NAME" \
--arg sourceBranch "$SOURCE_BRANCH" \
--arg repository "$REPOSITORY" \
--arg githubRunUrl "$GITHUB_RUN_URL" \
'{
releaseVersion: $releaseVersion,
tagName: $tagName,
sourceBranch: $sourceBranch,
repository: $repository,
githubRunUrl: $githubRunUrl,
dryRun: false
}')

RESP_FILE=$(mktemp)
trap 'rm -f "$RESP_FILE"' EXIT

# Invoke Otto silently without -S/-v so the signed webhook URL is never printed to logs.
CURL_EXIT=0
HTTP_STATUS=$(curl -s \
--connect-timeout 15 \
--max-time 60 \
--retry 2 \
--retry-delay 5 \
--retry-connrefused \
-X POST \
-H 'Content-Type: application/json' \
--data "$PAYLOAD" \
-o "$RESP_FILE" \
-w '%{http_code}' \
"$OTTO_WORKFLOW_URL") || CURL_EXIT=$?

if [[ "$CURL_EXIT" -ne 0 ]]; then
echo "::error::Failed to invoke Otto npm publish workflow (curl exit code: $CURL_EXIT)."
exit "$CURL_EXIT"
fi

- name: 'Publish to NPM'
run: pnpm run publish --no-git-checks --access public --tag latest
# Otto returns 200 when a matching publish is skipped/deduplicated and 202 when queued.
if [[ "$HTTP_STATUS" != "200" && "$HTTP_STATUS" != "202" ]]; then
echo "::error::Otto npm publish workflow returned HTTP $HTTP_STATUS."
if jq -e 'type == "object"' "$RESP_FILE" >/dev/null 2>&1; then
jq 'del(.url, .webhookUrl, .sasUrl, .token, .sig, .authorization, .headers)' "$RESP_FILE"
fi
exit 1
fi

if ! jq -e 'type == "object"' "$RESP_FILE" >/dev/null 2>&1; then
echo "::error::Otto npm publish workflow returned HTTP $HTTP_STATUS with an empty or non-JSON response."
exit 1
fi

PUBLISH_STATUS=$(jq -r '.status // "unknown"' "$RESP_FILE")
BUILD_ID=$(jq -r '.buildId // .existingBuildId // empty' "$RESP_FILE")
BUILD_URL=$(jq -r '.buildUrl // .existingBuildUrl // empty' "$RESP_FILE")

echo "Otto npm publish status: $PUBLISH_STATUS (HTTP $HTTP_STATUS)"
if [[ -n "$BUILD_ID" ]]; then
echo "ADO build ID: $BUILD_ID"
fi
if [[ -n "$BUILD_URL" ]]; then
echo "ADO build URL: $BUILD_URL"
fi

{
echo "### ADO npm Publish"
echo ""
echo "- **Version:** \`$RELEASE_VERSION\` (\`$TAG_NAME\`)"
echo "- **Status:** \`$PUBLISH_STATUS\` (HTTP \`$HTTP_STATUS\`)"
if [[ -n "$BUILD_ID" && -n "$BUILD_URL" ]]; then
echo "- **ADO Build:** [#$BUILD_ID]($BUILD_URL)"
elif [[ -n "$BUILD_ID" ]]; then
echo "- **ADO Build ID:** \`$BUILD_ID\`"
elif [[ -n "$BUILD_URL" ]]; then
echo "- **ADO Build URL:** $BUILD_URL"
fi
} >> "$GITHUB_STEP_SUMMARY"
Loading
Loading