Nightly Prerelease build on Main #43
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: Nightly Prerelease build on Main | |
on: | |
schedule: | |
- cron: '0 23 * * *' # This is 1:00 AM Berlin time | |
workflow_dispatch: # Allows manual triggering | |
env: | |
BRANCH_SUFFIX: latest | |
VERSION_SUFFIX: alpha | |
CREATE_RELEASE_AS_DRAFT: false | |
CREATE_RELEASE_AS_PRERELEASE: true | |
jobs: | |
check-for-changes: | |
runs-on: ubuntu-latest | |
name: Check for changes | |
# if: github.repository == 'eclipse-aaspe/server' | |
outputs: | |
changes_detected: ${{ steps.check_changes.outputs.changes_detected }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get the newest tag | |
id: get_latest_tag | |
run: | | |
git fetch --all | |
stableTags=$(git tag --list "*$BRANCH_SUFFIX*" --sort=-v:refname) | |
if [ -n "$stableTags" ]; then | |
newestStableTag=$(echo "$stableTags" | head -n 1) | |
echo "latest_tag=$newestStableTag" >> $GITHUB_ENV | |
echo "Latest found tag is $newestStableTag" | |
else | |
echo "No stable tags found, assuming there are changes." | |
echo "latest_tag=" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Check for changes | |
id: check_changes | |
run: | | |
if [ -z "${{ env.latest_tag }}" ]; then | |
echo "No latest tag found, assuming there are changes." | |
echo "changes_detected=true" >> $GITHUB_OUTPUT | |
else | |
git fetch origin main | |
latest_commit=$(git rev-parse HEAD) | |
if git diff --quiet ${{ env.latest_tag }} $latest_commit; then | |
echo "No changes detected since tag '${{ env.latest_tag }}'." | |
echo "changes_detected=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected since tag '${{ env.latest_tag }}'." | |
echo "changes_detected=true" >> $GITHUB_OUTPUT | |
fi | |
fi | |
shell: bash | |
create-new-prerelease: | |
runs-on: windows-latest | |
name: Create a new prerelease build and attach built packages to release | |
needs: check-for-changes | |
if: needs.check-for-changes.outputs.changes_detected == 'true' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set execution policy | |
run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process | |
shell: pwsh | |
- name: Extract branch name | |
id: extract_branch | |
run: | | |
git fetch --all | |
$commitSHA = git rev-parse HEAD | |
$branch = git branch -r --contains $commitSHA | Select-String -Pattern 'origin/' | Select-Object -First 1 | ForEach-Object { $_.Line -replace '.*origin/', '' } | ForEach-Object { $_.Trim() } | |
echo "branch=$branch" >> $env:GITHUB_OUTPUT | |
Write-Host "The current branch is: $branch" | |
shell: pwsh | |
- name: Get the newest tag | |
id: get_latest_tag | |
run: | | |
$stableTags = git tag --list "*$BRANCH_SUFFIX*" --sort=-v:refname | |
if ($stableTags) { | |
$newestStableTag = $stableTags | Select-Object -First 1 | |
echo "from_tag=$newestStableTag" >> $env:GITHUB_OUTPUT | |
Write-Host "Latest found tag is $newestStableTag" | |
} else { | |
Write-Host "No stable tags found, fetching the latest tag." | |
$latestTag = git tag --list --sort=-v:refname | Select-Object -First 1 | |
if ($latestTag) { | |
echo "from_tag=$latestTag" >> $env:GITHUB_OUTPUT | |
Write-Host "Latest found tag is $latestTag" | |
} else { | |
Write-Host "No tags found at all." | |
} | |
} | |
shell: pwsh | |
- name: Generate Version Number | |
working-directory: src | |
id: generate_version_number | |
run: | | |
$branch = '${{ steps.extract_branch.outputs.branch }}' | |
$version = .\BuildVersionNumber.ps1 -suffix $VERSION_SUFFIX -branch $branch -githubRunNumber ${{ github.run_number }} | |
echo "version=$version" >> $env:GITHUB_OUTPUT | |
Write-Host "The version name to build is: $version" | |
shell: pwsh | |
- name: Update version numbers in project | |
working-directory: src | |
run: | | |
$version = '${{ steps.generate_version_number.outputs.version }}' | |
Write-Host "Updating project versions to: $version" | |
.\UpdateProjectVersions.ps1 -version $version | |
shell: pwsh | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Build release | |
working-directory: src | |
run: .\BuildForRelease.ps1 | |
shell: pwsh | |
- name: Package release | |
working-directory: src | |
run: | | |
$version = '${{ steps.generate_version_number.outputs.version }}' | |
mkdir -p artefacts/release/$version | |
Write-Host "Packaging for the release version: $version" | |
.\PackageRelease.ps1 -version $version | |
shell: pwsh | |
- name: Rename the release assets | |
working-directory: . | |
run: | | |
$version = '${{ steps.generate_version_number.outputs.version }}' | |
$releaseDir = Join-Path $(Get-Location) "artefacts/release/$version" | |
Write-Host "Release directory: $releaseDir" | |
if (!(Test-Path $releaseDir)) { | |
throw "The release directory does not exist: $releaseDir" | |
} | |
$archives = Get-ChildItem $releaseDir -Filter *.zip | |
foreach($archive in $archives) { | |
$path = $archive.FullName | |
Write-Host "The path to the archive is: $path" | |
$nameWoExt = [io.path]::GetFileNameWithoutExtension($path) | |
Write-Host "The name without extension is: $nameWoExt" | |
$target = Join-Path $releaseDir ($nameWoExt + "." + $version + ".zip") | |
Write-Host "Moving: $path -> $target" | |
Move-Item -Path $path -Destination $target | |
} | |
shell: pwsh | |
- name: Create Git tag | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git tag ${{ steps.generate_version_number.outputs.version }} | |
git push origin ${{ steps.generate_version_number.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate release notes | |
id: generate_release_notes | |
uses: mikepenz/release-changelog-builder-action@v4 | |
with: | |
configuration: ".github/changelog_configuration.json" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fromTag: "${{ steps.get_latest_tag.outputs.from_tag }}" | |
toTag: "${{ steps.generate_version_number.outputs.version }}" | |
fetchViaCommits: "true" | |
ignorePreReleases: "false" | |
fetchReleaseInformation: "true" | |
failOnError: "true" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create GitHub release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ steps.generate_version_number.outputs.version }}" | |
name: "v${{ steps.generate_version_number.outputs.version }}" | |
draft: $CREATE_RELEASE_AS_DRAFT | |
prerelease: $CREATE_RELEASE_AS_PRERELEASE | |
body: ${{ steps.generate_release_notes.outputs.changelog }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload the release assets | |
uses: AButler/[email protected] | |
with: | |
files: "artefacts/release/${{ steps.generate_version_number.outputs.version }}/*.zip" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
release-tag: "v${{ steps.generate_version_number.outputs.version }}" | |
build-and-publish-docker-release-images: | |
runs-on: ubuntu-latest | |
name: Create new docker builds with latest prerelease and upload to DockerHub | |
needs: create-new-prerelease | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build and publish AasxServerBlazor | |
uses: docker/build-push-action@v1 | |
with: | |
username: adminshellio | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: adminshellio/aasx-server-blazor-for-demo | |
tag_with_ref: true | |
dockerfile: src/docker/Dockerfile-AasxServerBlazor | |
- name: Build and publish AasxServerBlazor-arm32 | |
uses: docker/build-push-action@v1 | |
with: | |
username: adminshellio | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: adminshellio/aasx-server-blazor-for-demo-arm32 | |
tag_with_ref: true | |
dockerfile: src/docker/Dockerfile-AasxServerBlazor-arm32 | |
- name: Build and publish AasxServerBlazor-arm64 | |
uses: docker/build-push-action@v1 | |
with: | |
username: adminshellio | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: adminshellio/aasx-server-blazor-for-demo-arm64 | |
tag_with_ref: true | |
dockerfile: src/docker/Dockerfile-AasxServerBlazor-arm64 | |
- name: Build and publish AasxServerCore | |
uses: docker/build-push-action@v1 | |
with: | |
username: adminshellio | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: adminshellio/aasx-server-aspnetcore-for-demo | |
tag_with_ref: true | |
dockerfile: src/docker/Dockerfile-AasxServerAspNetCore | |
- name: Build and publish AasxServerCore-arm32 | |
uses: docker/build-push-action@v1 | |
with: | |
username: adminshellio | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: adminshellio/aasx-server-aspnetcore-for-demo-arm32 | |
tag_with_ref: true | |
dockerfile: src/docker/Dockerfile-AasxServerAspNetCore-arm32 | |
- name: Build and publish AasxServerCore-arm64 | |
uses: docker/build-push-action@v1 | |
with: | |
username: adminshellio | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: adminshellio/aasx-server-aspnetcore-for-demo-arm64 | |
tag_with_ref: true | |
dockerfile: src/docker/Dockerfile-AasxServerAspNetCore-arm64 |