Skip to content

Commit

Permalink
template build
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Sep 6, 2024
1 parent 79536b7 commit cc72c69
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Suppress: EC112

[*.{vue,ts,js,scss,html,csproj,md,props,targets}]
[*.{vue,ts,js,scss,html,csproj,md,props,targets,yml}]
indent_style = space
indent_size = 2

Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ name: build-alpha
on:
push:
branches: [dev, next]
paths-ignore: ['docs/**']
paths-ignore: ['docs/**', 'templates/**']
pull_request:
branches: [dev, next]
paths-ignore: ['docs/**']
paths-ignore: ['docs/**', 'templates/**']
workflow_dispatch:

jobs:
meta:
uses: ./.github/workflows/part-compute-version.yml
secrets: inherit
with:
prereleaseSlug: ci

build:
uses: ./.github/workflows/part-build.yml
secrets: inherit
needs: meta
with:
prereleaseSlug: ci
COALESCE_VERSION: ${{ needs.meta.outputs.COALESCE_VERSION }}

publish:
if: success() && github.event_name == 'push'
Expand Down
94 changes: 6 additions & 88 deletions .github/workflows/part-build.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,23 @@
on:
workflow_call:
inputs:
prereleaseSlug:
required: false
type: string
checkTagIsUnique:
required: false
type: boolean
outputs:
COALESCE_VERSION:
description: "COALESCE_VERSION"
value: ${{ jobs.meta.outputs.COALESCE_VERSION }}
required: true
type: string

jobs:
meta:
runs-on: ubuntu-latest

outputs:
COALESCE_VERSION: ${{ steps.version.outputs.COALESCE_VERSION }}

steps:
- uses: actions/checkout@v3

- name: "Verify and set COALESCE_VERSION variable"
id: version
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$apiBaseUrl = "${{ github.api_url }}/repos/${{ github.repository }}/actions"
$runInfo = curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$apiBaseUrl/runs/${{ github.run_id }}";
$workflowId = $runInfo | jq -r .workflow_id;
$createdAt = $runInfo | jq -r .created_at;
$createdAtPST = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId( [System.DateTimeOffset](Get-Date -Date $createdAt), "America/Los_Angeles" );
echo "workflowId: $workflowId";
echo "createdAt: $createdAt ($createdAtPST)";
# Get how many runs of this workflow have happened today
$dateFormat = "yyyy-MM-ddT00:00:00K"
$revRequestUrl = "$apiBaseUrl/workflows/$workflowId/runs?created=$($createdAtPST.ToString($dateFormat))..$($createdAtPST.AddDays(1).ToString($dateFormat))";
$rev = curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $revRequestUrl | jq .total_count;
$path = "version.txt";
$version = "$((cat $path).Trim())"
$date = $createdAtPST.ToString("yyyyMMdd")
$prereleaseSlug = "${{ inputs.prereleaseSlug }}"
echo "Version from $($path): $version";
echo "Prerelease: $prereleaseSlug";
echo "Date: $date";
echo "Rev: $rev";
echo "checkTagIsUnique: ${{ inputs.checkTagIsUnique }}";
if ($prereleaseSlug) {
$version = "$version-$prereleaseSlug.$date.$rev"
}
echo "Computed version: $version";
try
{
[System.Management.Automation.SemanticVersion]::Parse($version);
}
catch
{
Write-Error "'$version' is an invalid SemVer version"
exit 1
}
if ("${{ inputs.checkTagIsUnique }}" -eq "true") {
if (git tag -l "$version") {
Write-Error "Tag $version already exists.";
exit 1;
}
}
echo "COALESCE_VERSION=$version" >> $env:GITHUB_OUTPUT
echo "# Version $version" >> $env:GITHUB_STEP_SUMMARY
build-dotnet:
needs: meta
runs-on: ubuntu-latest

env:
COALESCE_VERSION: ${{needs.meta.outputs.COALESCE_VERSION}}
COALESCE_VERSION: ${{inputs.COALESCE_VERSION}}

steps:
- uses: actions/checkout@v3
- name: Setup dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.0.x
8.0.x
include-prerelease: true

Expand All @@ -112,7 +36,6 @@ jobs:


validate-vue2-playground:
needs: meta
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -124,7 +47,6 @@ jobs:
- uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.0.x
8.0.x
include-prerelease: true

Expand All @@ -139,7 +61,6 @@ jobs:


validate-vue3-playground:
needs: meta
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -166,14 +87,13 @@ jobs:


build-coalesce-vue:
needs: meta
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/coalesce-vue

env:
COALESCE_VERSION: ${{needs.meta.outputs.COALESCE_VERSION}}
COALESCE_VERSION: ${{inputs.COALESCE_VERSION}}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -220,14 +140,13 @@ jobs:


build-coalesce-vue-vuetify2:
needs: meta
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/coalesce-vue-vuetify2

env:
COALESCE_VERSION: ${{needs.meta.outputs.COALESCE_VERSION}}
COALESCE_VERSION: ${{inputs.COALESCE_VERSION}}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -256,14 +175,13 @@ jobs:


build-coalesce-vue-vuetify3:
needs: meta
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/coalesce-vue-vuetify3

env:
COALESCE_VERSION: ${{needs.meta.outputs.COALESCE_VERSION}}
COALESCE_VERSION: ${{inputs.COALESCE_VERSION}}

steps:
- uses: actions/checkout@v3
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/part-compute-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
on:
workflow_call:
inputs:
prereleaseSlug:
required: false
type: string
checkTagIsUnique:
required: false
type: boolean
outputs:
COALESCE_VERSION:
description: "COALESCE_VERSION"
value: ${{ jobs.version.outputs.COALESCE_VERSION }}

jobs:
version:
runs-on: ubuntu-latest

outputs:
COALESCE_VERSION: ${{ steps.version.outputs.COALESCE_VERSION }}

steps:
- uses: actions/checkout@v3

- name: "Verify and set COALESCE_VERSION variable"
id: version
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$apiBaseUrl = "${{ github.api_url }}/repos/${{ github.repository }}/actions"
$runInfo = curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$apiBaseUrl/runs/${{ github.run_id }}";
$workflowId = $runInfo | jq -r .workflow_id;
$createdAt = $runInfo | jq -r .created_at;
$createdAtPST = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId( [System.DateTimeOffset](Get-Date -Date $createdAt), "America/Los_Angeles" );
echo "workflowId: $workflowId";
echo "createdAt: $createdAt ($createdAtPST)";
# Get how many runs of this workflow have happened today
$dateFormat = "yyyy-MM-ddT00:00:00K"
$revRequestUrl = "$apiBaseUrl/workflows/$workflowId/runs?created=$($createdAtPST.ToString($dateFormat))..$($createdAtPST.AddDays(1).ToString($dateFormat))";
$rev = curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $revRequestUrl | jq .total_count;
$path = "version.txt";
$version = "$((cat $path).Trim())"
$date = $createdAtPST.ToString("yyyyMMdd")
$prereleaseSlug = "${{ inputs.prereleaseSlug }}"
echo "Version from $($path): $version";
echo "Prerelease: $prereleaseSlug";
echo "Date: $date";
echo "Rev: $rev";
echo "checkTagIsUnique: ${{ inputs.checkTagIsUnique }}";
if ($prereleaseSlug) {
$version = "$version-$prereleaseSlug.$date.$rev"
}
echo "Computed version: $version";
try
{
[System.Management.Automation.SemanticVersion]::Parse($version);
}
catch
{
Write-Error "'$version' is an invalid SemVer version"
exit 1
}
if ("${{ inputs.checkTagIsUnique }}" -eq "true") {
if (git tag -l "$version") {
Write-Error "Tag $version already exists.";
exit 1;
}
}
echo "COALESCE_VERSION=$version" >> $env:GITHUB_OUTPUT
echo "# Version $version" >> $env:GITHUB_STEP_SUMMARY
24 changes: 19 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,37 @@ on:
- ''

jobs:
build:
uses: ./.github/workflows/part-build.yml
meta:
uses: ./.github/workflows/part-compute-version.yml
secrets: inherit
with:
prereleaseSlug: ${{ inputs.prereleaseSlug }}
checkTagIsUnique: true

build:
uses: ./.github/workflows/part-build.yml
secrets: inherit
needs: meta
with:
COALESCE_VERSION: ${{ needs.meta.outputs.COALESCE_VERSION }}

build-template:
uses: ./.github/workflows/template/part-build.yml
secrets: inherit
needs: meta
with:
COALESCE_VERSION: ${{ needs.meta.outputs.COALESCE_VERSION }}

publish:
uses: ./.github/workflows/part-publish.yml
needs: build
needs: [build, build-template]
secrets: inherit

create-release:
runs-on: ubuntu-latest
needs: [build, publish]
needs: [meta, publish]
steps:
- uses: actions/checkout@v3
- uses: rickstaa/action-create-tag@v1
with:
tag: ${{ needs.build.outputs.COALESCE_VERSION }}
tag: ${{ needs.meta.outputs.COALESCE_VERSION }}
Loading

0 comments on commit cc72c69

Please sign in to comment.