Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #45 from microsoft/edaena-homebrew
Browse files Browse the repository at this point in the history
Update homebrew package via the release pipeline
  • Loading branch information
edaena authored May 28, 2020
2 parents 6a5d243 + ce2aefa commit 8744034
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
8 changes: 8 additions & 0 deletions azure-pipelines/templates/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ jobs:
- publish: $(System.DefaultWorkingDirectory)/dist
artifact: dist

- script: |
package_version=$(cat $(System.DefaultWorkingDirectory)/package.json | grep "version" | sed -e 's/"version": "//g')
new_version=v${package_version%??}
echo $new_version| sed -e 's/ //g' > version.txt
- publish: $(System.DefaultWorkingDirectory)/version.txt
artifact: BedrockVersion
19 changes: 19 additions & 0 deletions azure-pipelines/templates/create-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ jobs:
steps:
- download: current

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Agent.BuildDirectory)/dist
includeRootFolder: true
archiveFile: $(Agent.BuildDirectory)/dist.tar.gz
replaceExistingArchive: true

- script: |
echo "Get sha256 number for dist.tar.gz"
file_sha=$(openssl dgst -sha256 $(Agent.BuildDirectory)/dist.tar.gz)
sha_number=$(echo $file_sha| sed -e 's/SHA256(.*)= //g')
version_tag=$(sed -n '1p' < $(Agent.BuildDirectory)/BedrockVersion/version.txt)
echo -e $version_tag >> $(Agent.BuildDirectory)/package-info.txt
echo -e $sha_number >> $(Agent.BuildDirectory)/package-info.txt
- publish: $(Agent.BuildDirectory)/package-info.txt
artifact: BedrockPackage

- task: GitHubRelease@1
displayName: "GitHub release ${{ parameters.action }}"
inputs:
Expand All @@ -28,6 +46,7 @@ jobs:
$(Agent.BuildDirectory)/dist/bedrock-linux
$(Agent.BuildDirectory)/dist/bedrock-macos
$(Agent.BuildDirectory)/dist/bedrock-win.exe
$(Agent.BuildDirectory)/dist.tar.gz
tagSource: ${{ parameters.tagSource }}
isDraft: ${{ parameters.isDraft }}
isPreRelease: ${{ parameters.isPrelease }}
Expand Down
50 changes: 50 additions & 0 deletions azure-pipelines/templates/update-homebrew-formula.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

jobs:
- job: Update_Homebrew_Formula
timeoutInMinutes: 30 # timeout on job if deploy is not completed in 30 minutes
pool:
vmImage: ubuntu-16.04
steps:
- download: current

- task: DownloadPipelineArtifact@2
inputs:
artifact: 'BedrockPackage'
path: $(Agent.BuildDirectory)

- checkout: BedrockHomebrewCore
persistCredentials: true
clean: true

- script: |
# Read version and sha256 number
sha_number=$(sed -n '2p' < $(Agent.BuildDirectory)/BedrockPackage/package-info.txt)
version_tag=$(sed -n '1p' < $(Agent.BuildDirectory)/BedrockPackage/package-info.txt)
echo "version tag"
echo $version_tag
dir $(Build.SourcesDirectory)
cd $(Build.SourcesDirectory)
# Add changes to the homebrew formula repository
git pull origin master
git checkout -b master
# Set git identity
git config user.email "admin@azuredevops.com"
git config user.name "Automated Account"
cd Formula
# Parse homebrew formula file to update the version, commit and push
echo "Updating bedrock-cli.rb formula file on bedrock homebrew repository."
sed -i "s/\/v.*\//\/$version_tag\//g" bedrock-cli.rb
cat bedrock-cli.rb
sed -i "s/sha256 \".*\"/sha256 \"$sha_number\"/g" bedrock-cli.rb
cat bedrock-cli.rb
echo "Add and push new version changes."
git add -f bedrock-cli.rb
git commit -m "Update formula with new release."
git push origin master
12 changes: 12 additions & 0 deletions release-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ trigger:

pr: none # disable CI build for PR

resources:
repositories:
- repository: BedrockHomebrewCore # The name used to reference this repository in the checkout step
type: github
endpoint: "bedrock-cli"
name: microsoft/homebrew-bedrock

stages:
- stage: package_build
jobs:
Expand All @@ -24,3 +31,8 @@ stages:
tagSource: "gitTag" # or "userSpecifiedTag"
addChangeLog: true
isDraft: true

- stage: update_homebrew_package
dependsOn: github_release
jobs:
- template: azure-pipelines/templates/update-homebrew-formula.yml

0 comments on commit 8744034

Please sign in to comment.