From ac932a027071e617cd0c3088ef8014f9db725d2f Mon Sep 17 00:00:00 2001
From: Wael Kdouh <waekdo@microsoft.com>
Date: Fri, 2 Dec 2022 11:01:02 -0500
Subject: [PATCH] Updated the publisher and release pipelines

---
 .github/workflows/create_github_release.yaml  | 24 ++++++++++++++++++-
 .../run-publisher-with-env.yaml               | 22 +++++++++--------
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/create_github_release.yaml b/.github/workflows/create_github_release.yaml
index af914d9c..d177a761 100644
--- a/.github/workflows/create_github_release.yaml
+++ b/.github/workflows/create_github_release.yaml
@@ -75,4 +75,26 @@ jobs:
         uses: actions/upload-artifact@v2
         with:
           name: artifacts
-          path: ${{ GITHUB.WORKSPACE }}/finalartifacts
\ No newline at end of file
+          path: ${{ GITHUB.WORKSPACE }}/finalartifacts
+      
+    
+  Generate_Release:
+   needs: Generate_Artifacts
+   runs-on: [ubuntu-latest]
+   steps:
+   - name: Download artifacts
+     uses: actions/download-artifact@v2
+     with:
+       name: artifacts
+       path: ${{ GITHUB.WORKSPACE }}/finalartifacts
+   - name: Release
+     uses: softprops/action-gh-release@v1
+     with:
+       files: |
+         ${{github.workspace}}/finalartifacts/extractor
+         ${{github.workspace}}/finalartifacts/publisher
+         ${{github.workspace}}/finalartifacts/Azure_DevOps.zip
+         ${{github.workspace}}/finalartifacts/Github.zip
+       name: APIOps Toolkit for Azure APIM ${{ github.event.inputs.Release_Version }}
+       tag_name: ${{ github.event.inputs.Release_Version }}
+       generate_release_notes: true
diff --git a/tools/azdo_pipelines/run-publisher-with-env.yaml b/tools/azdo_pipelines/run-publisher-with-env.yaml
index 8e0e71f1..f5c01d91 100644
--- a/tools/azdo_pipelines/run-publisher-with-env.yaml
+++ b/tools/azdo_pipelines/run-publisher-with-env.yaml
@@ -40,14 +40,6 @@ steps:
 - script: spectral lint "$(Build.SourcesDirectory)\${{ parameters.API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH }}\apis\*.{json,yml,yaml}" --ruleset https://raw.githubusercontent.com/connectedcircuits/devops-api-linter/main/rules.yaml
   displayName: 'Lint API definition' 
 
-- task: UniversalPackages@0
-  displayName: Download publisher
-  inputs:
-    downloadDirectory: '$(Pipeline.Workspace)/publisher'
-    vstsFeed: $(System.TeamProject)/$(ARTIFACTS_FEED_NAME)
-    vstsFeedPackage: 'publisher'
-    vstsPackageVersion: '*'
-
 - task: AzureCLI@2
   displayName: Set publishing variables
   inputs:
@@ -76,6 +68,16 @@ steps:
     tokenPrefix: "{#"
     tokenSuffix: "#}"
 
+- task: Bash@3
+  displayName: Fetch publisher
+  inputs:
+    targetType: 'inline'
+    script: |
+      wget https://github.com/Azure/apiops/releases/download/$(apiops_release_version)/publisher
+      result=$?
+      echo "Exit code is $result"
+      exit $result
+    failOnStderr: false
 
 - task: AzureCLI@2
   displayName: Run publisher for ${{ parameters.ENVIRONMENT}} environment
@@ -84,8 +86,8 @@ steps:
     scriptType: bash
     scriptLocation: inlineScript
     inlineScript: |
-      chmod u+x $(Pipeline.Workspace)/publisher/publisher
-      $(Pipeline.Workspace)/publisher/publisher
+      chmod +x ./publisher
+      ./publisher
       result=$?
       echo "Exit code is $result"
       exit $result