Create AIO Release #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create AIO Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to publish' | |
required: true | |
type: string | |
jobs: | |
Version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.templateVersion.outputs.version }} | |
steps: | |
- name: Verify Repo | |
run: |- | |
allowed_repositories=("Azure/azure-iot-operations-pr" "Azure/azure-iot-operations") | |
if [[ ! " ${allowed_repositories[@]} " =~ " ${{ github.repository }} " ]]; then | |
echo "::error::This workflow should not be run in this repository" | |
exit 1 | |
fi | |
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then | |
echo "::error::This workflow should only be run on the main branch" | |
exit 1 | |
fi | |
- name: Set Version | |
id: templateVersion | |
run: |- | |
set -e | |
# strip spaces from version | |
version=$(echo "${{ github.event.inputs.version }}" | tr -d '[:space:]') | |
if [[ -z "$version" ]]; then | |
echo "::error::Valid version is required" | |
fi | |
echo "Set version to $version" | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
PreRelease: | |
runs-on: ubuntu-latest | |
needs: Version | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Build Assets | |
uses: azure/CLI@v1 | |
id: buildAssets | |
with: | |
inlineScript: |- | |
files=() | |
if [[ -d samples/grafana-dashboards ]]; then | |
zip -r -9 grafana-dashboard.zip samples/grafana-dashboards | |
files+=("grafana-dashboard.zip") | |
fi | |
if [[ -f dev/azure-iot-operations.bicep ]]; then | |
az bicep build -f dev/azure-iot-operations.bicep | |
files+=("dev/azure-iot-operations.json") | |
elif [[ -f release/azure-iot-operations.json ]]; then | |
files+=("release/azure-iot-operations.json") | |
fi | |
if [[ -f .integration-lab/int-deployment.bicep ]]; then | |
az bicep build -f .integration-lab/int-deployment.bicep | |
files+=(".integration-lab/int-deployment.json") | |
fi | |
filelist=$(IFS=,; echo "${files[*]}") | |
echo "filelist=\"$filelist\"" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: createRelease | |
run: |- | |
set -e | |
gh auth login --with-token <<< "${{ github.token }}" | |
url=$(gh release create "${{ needs.Version.outputs.version }}" \ | |
--draft \ | |
--latest \ | |
--prerelease \ | |
--target "${{ github.ref }}" \ | |
--repo "${{ github.repository }}" \ | |
--title "${{ needs.Version.outputs.version }}" \ | |
$(echo "${{ steps.buildAssets.outputs.filelist }}" | tr "," " ")) | |
echo "url=$url" >> $GITHUB_OUTPUT | |
- name: Summarize | |
run: |- | |
IFS=',' read -r -a files <<< "${{ steps.buildAssets.outputs.filelist }}" | |
echo "# PreRelease ${{ needs.Version.outputs.version }} created" >> $GITHUB_STEP_SUMMARY | |
echo "A draft release has been created with the following assets:" >> $GITHUB_STEP_SUMMARY | |
for file in "${files[@]}"; do | |
echo "- $file" >> $GITHUB_STEP_SUMMARY | |
done | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "The release can be found [here](${{ steps.createRelease.outputs.url }})" >> $GITHUB_STEP_SUMMARY |