Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Aug 19, 2020
1 parent 4fe8ec0 commit 2fd1a5a
Showing 3 changed files with 149 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Unix/configure
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ if [ -n "$OMI_BUILDVERSION_MAJOR" -a -n "$OMI_BUILDVERSION_MINOR" -a -n "$OMI_BU
minor=$OMI_BUILDVERSION_MINOR
revision=$OMI_BUILDVERSION_PATCH
else
echo "*** UNABLE TO LOCATE FILE omi.version; USING VERSION 0.0.0.0 ***" >& 2
echo "*** UNABLE TO LOCATE FILE omi.version; USING VERSION 0.0.0 ***" >& 2

major=0
minor=0
@@ -51,6 +51,7 @@ patch_level=${OMI_BUILDVERSION_BUILDNR:-0}

version="$major.$minor.$revision"
version_with_release="$major.$minor.$revision-$patch_level"
echo "*** RELEASE: ${version_with_release} ***"
date=`date`

##==============================================================================
63 changes: 63 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -37,6 +37,29 @@ stages:
distribution: ubuntu18.04

steps:
- script: |
echo "'$(Build.Reason)'"
echo "'$(Build.SourceBranch)'"
echo "'$(Build.SourceVersionMessage)'"
- script: echo hi
condition: eq(variables['Build.Reason'], 'IndividualCI')

- script: echo hi
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')

- script: echo hi
condition: startsWith(variables['Build.SourceVersionMessage'], 'release ')

- script: echo hi
condition: >-
and(
succeeded(),
eq(variables['Build.Reason'], 'IndividualCI'),
eq(variables['Build.SourceBranch'], 'refs/heads/main'),
startsWith(variables['Build.SourceVersionMessage'], 'release ')
)
- script: ./build.py $(distribution) --docker
env:
OMI_BUILDVERSION_BUILDNR: $(Build.BuildId)
@@ -61,3 +84,43 @@ stages:
inputs:
targetPath: Unix/build-macOS/lib/libmi.dylib
artifactName: macOS-libmi

- stage: Publish
jobs:
- job: Publish
pool:
vmImage: ubuntu-18.04

steps:
- script: |
RELEASE_TAG="$( ./release.py --print-tag )"
echo "Derived release tag is ${RELEASE_TAG}"
echo "##vso[task.setvariable variable=ReleaseTag]${RELEASE_TAG}"
displayName: Generate the tag number from omi.version
- task: DownloadPipelineArtifact@2
inputs:
source: current
path: $(Build.ArtifactStagingDirectory)

- script: ./release.py --pipeline-artifacts "$(Build.ArtifactStagingDirectory)"
displayName: Rename the published artifacts for the GitHub release assets

- task: GitHubRelease@0
inputs:
gitHubConnection: GitHub Release
repositoryName: $(Build.Repository.Name)
action: create
target: $(Build.SourceVersion)
tagSource: manual
tag: $(ReleaseTag)
assets: $(Build.ArtifactStagingDirectory)/*
addChangeLog: true
compareWith: lastFullRelease
condition: >-
and(
succeeded(),
eq(variables['Build.Reason'], 'IndividualCI'),
eq(variables['Build.SourceBranch'], 'refs/heads/main'),
startsWith(variables['Build.SourceVersionMessage'], 'release ')
)
84 changes: 84 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK

# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import argparse
import os
import os.path

from utils import (
argcomplete,
OMI_REPO,
)


def main():
"""Main program body."""
args = parse_args()

if args.print_tag:
with open(os.path.join(OMI_REPO, 'omi.version'), mode='r') as fd:
version_lines = fd.read().splitlines()

version_info = {}
for line in version_lines:
k, v = line.split('=', 1)
version_info[k] = v

print("v%s.%s.%s-pwsh" % (version_info['OMI_BUILDVERSION_MAJOR'], version_info['OMI_BUILDVERSION_MINOR'],
version_info['OMI_BUILDVERSION_PATCH']))

elif args.pipeline_artifacts:
# This renames the Azure DevOps pipeline files to the format desired for a GitHub release asset
for name in os.listdir(args.pipeline_artifacts):
if not name.endswith('-libmi'):
continue

artifact_dir = os.path.join(args.pipeline_artifacts, name)

distribution = name.rstrip('-libmi')
lib_name = os.listdir(artifact_dir)[0]
lib_ext = os.path.splitext(lib_name)[-1]

src_path = os.path.join(artifact_dir, lib_name)
dest_path = os.path.join(args.pipeline_artifacts, 'libmi-%s%s' % (distribution, lib_ext))

print("Renaming '%s' -> '%s'" % (src_path, dest_path))
os.rename(src_path, dest_path)
os.rmdir(artifact_dir)


def parse_args():
"""Parse and return args."""
parser = argparse.ArgumentParser(description='Release helpers for the OMI library in PowerShell.')

run_group = parser.add_mutually_exclusive_group()

run_group.add_argument('--print-tag',
dest='print_tag',
action='store_true',
help='Print the tag number for the release.')

run_group.add_argument('--pipeline-artifacts',
dest='pipeline_artifacts',
action='store',
help='The Azure DevOps pipeline artifact store directory to process.')

if argcomplete:
argcomplete.autocomplete(parser)

args = parser.parse_args()

if not args.print_tag and not args.pipeline_artifacts:
parser.error('argument --print-tag or --pipeline-artifacts must be seet')

return args


if __name__ == '__main__':
main()

0 comments on commit 2fd1a5a

Please sign in to comment.