Skip to content

Create draft release #12

Create draft release

Create draft release #12

name: Create draft release
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "The release version, for example 2.0.0."
required: true
env:
VERSION: ${{ inputs.releaseVersion }}
DOTNET_VERSION: "6.0.x"
jobs:
BuildAndPushDockerImages:
strategy:
matrix:
image:
- amd64
- arm32v7
- arm64v8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v3
id: buildx
with:
install: true
- name: Login to docker hub
run: |
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push images
run: |
docker buildx build -f "./LoRaEngine/modules/LoRaWanNetworkSrvModule/Dockerfile.${{ matrix.image }}" -t $DOCKERHUB_ORGANISATION/lorawannetworksrvmodule:$VERSION-${{ matrix.image }} --output type=image,push=true "."
docker buildx build -f "./LoRaEngine/modules/LoRaBasicsStationModule/Dockerfile.${{ matrix.image }}" -t $DOCKERHUB_ORGANISATION/lorabasicsstationmodule:$VERSION-${{ matrix.image }} --build-arg CONTAINER_REGISTRY_ADDRESS=docker.io --output type=image,push=true "."
env:
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKER_REPOSITORY }}
CreateManifests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v3
id: buildx
with:
install: true
- name: Login to docker hub
run: |
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Create manifests
run: |
docker buildx imagetools create -t $DOCKERHUB_ORGANISATION/lorawannetworksrvmodule:$VERSION \
$DOCKERHUB_ORGANISATION/lorawannetworksrvmodule:$VERSION-amd64 \
$DOCKERHUB_ORGANISATION/lorawannetworksrvmodule:$VERSION-arm32v7 \
$DOCKERHUB_ORGANISATION/lorawannetworksrvmodule:$VERSION-arm64v8
docker buildx imagetools create -t $DOCKERHUB_ORGANISATION/lorabasicsstationmodule:$VERSION \
$DOCKERHUB_ORGANISATION/lorabasicsstationmodule:$VERSION-amd64 \
$DOCKERHUB_ORGANISATION/lorabasicsstationmodule:$VERSION-arm32v7 \
$DOCKERHUB_ORGANISATION/lorabasicsstationmodule:$VERSION-arm64v8
needs:
[BuildAndPushDockerImages]
env:
DOCKERHUB_ORGANISATION: ${{ secrets.DOCKER_REPOSITORY }}
CreateBranchToUpdateDoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: docs/main
- name: Update doc URL with new version
run: sed -r -i "s/iotedge-lorawan-starterkit%2Fv[0-9\.]+/iotedge-lorawan-starterkit%2Fv${VERSION}/g" docs/quickstart.md
- name: Set up git user using the built-in token
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create branch
run: |
BRANCH_NAME="docs/release-${VERSION}-${{ github.run_id }}"
DESCRIPTION="Update button URL with version $VERSION."
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "DESCRIPTION=$DESCRIPTION" >> $GITHUB_ENV
git checkout -b $BRANCH_NAME
git add docs/quickstart.md
git commit -m "$DESCRIPTION"
git push --set-upstream origin $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CreateBranchToUpdateBicep:
runs-on: ubuntu-latest
env:
ARM_FILE: Template/azuredeploy.json
steps:
- uses: actions/checkout@v4
with:
ref: dev
- name: Update the default LoRaWAN Starter Kit version to use in Bicep.
run: |
sed -r -i "s/param version string = '[0-9/.]+'/param version string = '${VERSION}'/g" TemplateBicep/main.bicep
- name: Generate ARM file
run: |
mkdir Template
az bicep build --file TemplateBicep/main.bicep --outfile $ARM_FILE
- name: Set up git user using the built-in token
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create branch
run: |
BRANCH_NAME="feature/update-version-${VERSION}-${{ github.run_id }}"
DESCRIPTION="Update the default LoRaWAN Starter Kit version to use in Bicep and ARM with version $VERSION."
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "DESCRIPTION=$DESCRIPTION" >> $GITHUB_ENV
git checkout -b $BRANCH_NAME
git add TemplateBicep/main.bicep
git add $ARM_FILE
git commit -m "$DESCRIPTION"
git push --set-upstream origin $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CreateDraftRelease:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3.2.0
with:
global-json-file: global.json
- name: Package Azure Function
run: |
dotnet publish LoRaEngine/LoraKeysManagerFacade -c Release
FUNCTION_ZIP=function-${VERSION}.zip
cd LoRaEngine/LoraKeysManagerFacade/bin/Release/net${DOTNET_VERSION%??} && zip -r $FUNCTION_ZIP .
# Define FUNCTION_ZIP env var for next steps.
echo "FUNCTION_ZIP=LoRaEngine/LoraKeysManagerFacade/bin/Release/net${DOTNET_VERSION%??}/$FUNCTION_ZIP" >> $GITHUB_ENV
- name: Package Discovery Service
run: |
dotnet publish LoRaEngine/modules/LoRaWan.NetworkServerDiscovery/LoRaWan.NetworkServerDiscovery.csproj -c Release
PUBLISH_FOLDER=LoRaEngine/modules/LoRaWan.NetworkServerDiscovery/bin/Release/net${DOTNET_VERSION%??}/publish
DISCOVERY_SERVICE_ZIP=discoveryservice-${VERSION}.beta1.zip
zip -r $DISCOVERY_SERVICE_ZIP $PUBLISH_FOLDER
# Define DISCOVERY_SERVICE_ZIP env var for next steps.
echo "DISCOVERY_SERVICE_ZIP=$DISCOVERY_SERVICE_ZIP" >> $GITHUB_ENV
- name: Update the default LoRaWAN Starter Kit version to use in Bicep.
run: sed -r -i "s/param version string = '[0-9/.]+'/param version string = '${VERSION}'/g" TemplateBicep/main.bicep
- name: Compile provisioning CLI for different platform
working-directory: Tools/Cli-LoRa-Device-Provisioning
shell: pwsh
run: pwsh BuildForRelease.ps1
- name: Create Draft release
run: |
CLI_RELEASE_PATH=Tools/Cli-LoRa-Device-Provisioning/LoRaWan.Tools.CLI/bin/Release/net${DOTNET_VERSION%??}
gh release create v$VERSION $FUNCTION_ZIP $DISCOVERY_SERVICE_ZIP \
$CLI_RELEASE_PATH/linux-x64/lora-cli.linux-x64.tar.gz \
$CLI_RELEASE_PATH/linux-musl-x64/lora-cli.linux-musl-x64.tar.gz \
$CLI_RELEASE_PATH/win-x64/lora-cli.win-x64.zip \
$CLI_RELEASE_PATH/osx-x64/lora-cli.osx-x64.zip \
--title "Release v$VERSION" --draft --repo ${{ github.repository }} --notes ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
needs:
[BuildAndPushDockerImages, CreateManifests, CreateBranchToUpdateDoc, CreateBranchToUpdateBicep]