Skip to content

Create release - Version 1.0.4 #1

Create release - Version 1.0.4

Create release - Version 1.0.4 #1

name: ' Create release'
run-name: "Create release - Version ${{ inputs.tag }}"
concurrency:
group: ${{ github.workflow }}
on:
workflow_dispatch:
inputs:
buildVersion:
description: Build version to promote to release (default is latest)
required: false
default: 'latest'
name:
description: Name of this release
required: true
default: ''
tag:
description: Tag of this release (needs to be semantic version string https://semver.org, ex. 1.0.0)
required: true
default: ''
releaseType:
description: Release, prerelease or draft?
type: choice
options:
- Release
- Prerelease
- Draft
default: Release
createReleaseBranch:
description: Create Release Branch?
type: boolean
default: false
releaseBranchPrefix:
description: The prefix for the release branch. Used only if 'Create Release Branch?' is checked.
type: string
default: release/
updateVersionNumber:
description: New Version Number in main branch. Use Major.Minor (optionally add .Build for versioningstrategy 3) for absolute change, or +1, +0.1 (or +0.0.1 for versioningstrategy 3) incremental change.
required: false
default: ''
skipUpdatingDependencies:
description: Skip updating dependency version numbers in all apps.
type: boolean
default: false
directCommit:
description: Direct Commit?
type: boolean
default: false
useGhTokenWorkflow:
description: Use GhTokenWorkflow for PR/Commit?
type: boolean
default: false
permissions:
actions: read
contents: write
id-token: write
pull-requests: write
defaults:
run:
shell: powershell
env:
ALGoOrgSettings: ${{ vars.ALGoOrgSettings }}
ALGoRepoSettings: ${{ vars.ALGoRepoSettings }}
jobs:
CreateRelease:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
artifacts: ${{ steps.determineArtifactsForRelease.outputs.artifacts }}
releaseId: ${{ steps.createrelease.outputs.releaseId }}
commitish: ${{ steps.determineArtifactsForRelease.outputs.commitish }}
releaseVersion: ${{ steps.createreleasenotes.outputs.releaseVersion }}
telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
steps:
- name: Dump Workflow Information
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Initialize the workflow
id: init
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
- name: Read settings
id: ReadSettings
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
get: templateUrl,repoName,type,powerPlatformSolutionFolder
- name: Validate Workflow Input
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
- name: Read secrets
id: ReadSecrets
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
gitHubSecrets: ${{ toJson(secrets) }}
getSecrets: 'TokenForPush,ghTokenWorkflow'
useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}'
- name: Determine Projects
id: determineProjects
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
- name: Check for updates to AL-Go system files
uses: microsoft/AL-Go-Actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
shell: powershell
templateUrl: ${{ env.templateUrl }}
token: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).ghTokenWorkflow }}
downloadLatest: true
- name: Determine artifacts for release
uses: microsoft/AL-Go-Actions/[email protected]
id: determineArtifactsForRelease
with:
shell: powershell
buildVersion: ${{ github.event.inputs.buildVersion }}
GITHUB_TOKEN: ${{ github.token }}
TOKENFORPUSH: ${{ steps.ReadSecrets.outputs.TokenForPush }}
ProjectsJson: ${{ steps.determineProjects.outputs.ProjectsJson }}
- name: Prepare release notes
id: createreleasenotes
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
buildVersion: ${{ github.event.inputs.buildVersion }}
tag_name: ${{ github.event.inputs.tag }}
target_commitish: ${{ steps.determineArtifactsForRelease.outputs.commitish }}
- name: Create release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: createrelease
env:
bodyMD: ${{ steps.createreleasenotes.outputs.releaseNotes }}
tag_name: ${{ github.event.inputs.tag }}
name: ${{ github.event.inputs.name }}
releaseType: ${{ github.event.inputs.releaseType }}
prerelease: ${{ github.event.inputs.releaseType == 'Prerelease' }}
commitish: ${{ steps.determineArtifactsForRelease.outputs.commitish }}
with:
github-token: ${{ steps.ReadSecrets.outputs.TokenForPush }}
script: |
var bodyMD = process.env.bodyMD
const createReleaseResponse = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.tag_name,
name: process.env.name,
body: bodyMD.replaceAll('\\n','\n').replaceAll('%0A','\n').replaceAll('%0D','\n').replaceAll('%25','%'),
draft: (process.env.releaseType == 'Draft'),
prerelease: (process.env.releaseType == 'Prerelease'),
make_latest: 'legacy',
target_commitish: process.env.commitish
});
const {
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl }
} = createReleaseResponse;
core.setOutput('releaseId', releaseId);
UploadArtifacts:
needs: [ CreateRelease ]
runs-on: [ windows-latest ]
name: Upload ${{ matrix.name }}
strategy:
matrix: ${{ fromJson(needs.CreateRelease.outputs.artifacts) }}
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Read settings
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
- name: Read secrets
id: ReadSecrets
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
gitHubSecrets: ${{ toJson(secrets) }}
getSecrets: 'nuGetContext,storageContext,TokenForPush'
useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}'
- name: Download artifact
env:
GITHUB_TOKEN: ${{ github.token }}
MATRIX_NAME: ${{ matrix.name }}
MATRIX_URL: ${{ matrix.url }}
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
Write-Host "Downloading artifact $ENV:MATRIX_NAME"
$headers = @{
"Authorization" = "token $ENV:GITHUB_TOKEN"
"X-GitHub-Api-Version" = "2022-11-28"
"Accept" = "application/vnd.github+json"
}
Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $ENV:MATRIX_URL -OutFile "$($ENV:MATRIX_NAME).zip"
- name: Upload release artifacts
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
releaseId: ${{ needs.createrelease.outputs.releaseId }}
MATRIX_NAME: ${{ matrix.name }}
with:
github-token: ${{ steps.ReadSecrets.outputs.TokenForPush }}
script: |
const releaseId = process.env.releaseId
const matrixName = process.env.MATRIX_NAME
const assetPath = `${matrixName}.zip`
const assetName = encodeURIComponent(`${matrixName}.zip`.replaceAll(' ','.')).replaceAll('%','')
const fs = require('fs');
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
name: assetName,
data: fs.readFileSync(assetPath)
});
- name: Deliver to NuGet
uses: microsoft/AL-Go-Actions/[email protected]
if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).nuGetContext != '' }}
env:
Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}'
with:
shell: powershell
type: 'Release'
projects: ${{ matrix.project }}
deliveryTarget: 'NuGet'
artifacts: ${{ github.event.inputs.buildVersion }}
atypes: 'Apps,TestApps'
- name: Deliver to Storage
uses: microsoft/AL-Go-Actions/[email protected]
if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).storageContext != '' }}
env:
Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}'
with:
shell: powershell
type: 'Release'
projects: ${{ matrix.project }}
deliveryTarget: 'Storage'
artifacts: ${{ github.event.inputs.buildVersion }}
atypes: 'Apps,TestApps,Dependencies'
CreateReleaseBranch:
needs: [ CreateRelease, UploadArtifacts ]
if: ${{ github.event.inputs.createReleaseBranch=='true' }}
runs-on: [ windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: '${{ needs.createRelease.outputs.commitish }}'
- name: Create Release Branch
env:
releaseBranchPrefix: ${{ github.event.inputs.releaseBranchPrefix }}
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
$releaseBranch = "$($env:releaseBranchPrefix)" + "${{ needs.CreateRelease.outputs.releaseVersion }}"
Write-Host "Creating release branch $releaseBranch"
git checkout -b $releaseBranch
git config user.name ${{ github.actor}}
git config user.email ${{ github.actor}}@users.noreply.github.com
git commit --allow-empty -m "Release branch $releaseBranch"
git push origin $releaseBranch
UpdateVersionNumber:
needs: [ CreateRelease, UploadArtifacts ]
if: ${{ github.event.inputs.updateVersionNumber!='' }}
runs-on: [ windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Read settings
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
- name: Read secrets
id: ReadSecrets
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
gitHubSecrets: ${{ toJson(secrets) }}
getSecrets: 'TokenForPush'
useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}'
- name: Update Version Number
uses: microsoft/AL-Go-Actions/[email protected]
with:
shell: powershell
token: ${{ steps.ReadSecrets.outputs.TokenForPush }}
versionNumber: ${{ github.event.inputs.updateVersionNumber }}
skipUpdatingDependencies: ${{ github.event.inputs.skipUpdatingDependencies }}
directCommit: ${{ github.event.inputs.directCommit }}
PostProcess:
needs: [ CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ]
if: always()
runs-on: [ windows-latest ]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Finalize the workflow
id: PostProcess
uses: microsoft/AL-Go-Actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
shell: powershell
telemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }}
currentJobContext: ${{ toJson(job) }}