From 4d7d12fe5f0e50c609a1d0ccce787223f78c600b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 16:56:04 +0100 Subject: [PATCH 01/13] CI test --- .github/workflows/github-actions-demo.yml | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..f263235 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,24 @@ +name: Alma build + +on: [push] + +jobs: + build: + runs-on: ${{ matrix.target.runner }} + strategy: + matrix: + target: + - triple: x86_64-pc-windows-gnu + runner: windows-latest + - triple: x86_64-unknown-linux-gnu + runner: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7.0.x' + - name: Install dependencies + run: dotnet restore src/Alma + - name: Build + run: dotnet build src/Alma From ddb452893d601f5ea9dd7edb422907d2a740d9a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:04:10 +0100 Subject: [PATCH 02/13] Dotnet publish, publish artifact --- .github/workflows/github-actions-demo.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index f263235..b4f0a6f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -8,10 +8,12 @@ jobs: strategy: matrix: target: - - triple: x86_64-pc-windows-gnu + - runtime: x86_64-pc-windows-gnu runner: windows-latest - - triple: x86_64-unknown-linux-gnu + name: windows + - runtime: x86_64-unknown-linux-gnu runner: ubuntu-latest + name: linux steps: - uses: actions/checkout@v3 - name: Setup dotnet @@ -21,4 +23,8 @@ jobs: - name: Install dependencies run: dotnet restore src/Alma - name: Build - run: dotnet build src/Alma + run: dotnet publish -r ${{ matrix.target.runtime }} -o /app/ src/Alma + - uses: actions/upload-artifact@v3 + with: + name: alma-${{ matrix.target.name }} + path: /app/ From ad65c6192772fd3709039e1e9268130413c13737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:08:23 +0100 Subject: [PATCH 03/13] Fix dotnet RID --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b4f0a6f..74edacb 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -8,10 +8,10 @@ jobs: strategy: matrix: target: - - runtime: x86_64-pc-windows-gnu + - runtime: win-x64 runner: windows-latest name: windows - - runtime: x86_64-unknown-linux-gnu + - runtime: linux-x64 runner: ubuntu-latest name: linux steps: From 89438a693551c717cdfd787f0824de7626590097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:09:46 +0100 Subject: [PATCH 04/13] Fix build path --- .github/workflows/github-actions-demo.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 74edacb..114462f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -20,11 +20,11 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: '7.0.x' - - name: Install dependencies + - name: Restore dependencies run: dotnet restore src/Alma - name: Build - run: dotnet publish -r ${{ matrix.target.runtime }} -o /app/ src/Alma + run: dotnet publish -r ${{ matrix.target.runtime }} -o app/ src/Alma - uses: actions/upload-artifact@v3 with: name: alma-${{ matrix.target.name }} - path: /app/ + path: app/ From d31bdbda40031a6781a538734d2e50b40b0a7171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:14:03 +0100 Subject: [PATCH 05/13] Publish Aot --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 114462f..6b4623a 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -23,7 +23,7 @@ jobs: - name: Restore dependencies run: dotnet restore src/Alma - name: Build - run: dotnet publish -r ${{ matrix.target.runtime }} -o app/ src/Alma + run: dotnet publish -c Release -p:PublishAot=true -r ${{ matrix.target.runtime }} -o app/ src/Alma - uses: actions/upload-artifact@v3 with: name: alma-${{ matrix.target.name }} From 525699ef1fb6c430a3270e11b7d6f4a4dce83ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:17:57 +0100 Subject: [PATCH 06/13] Add only executable to the artifact --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 6b4623a..160ed30 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -27,4 +27,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: alma-${{ matrix.target.name }} - path: app/ + path: app/Alma From 2e90190a9770be6d0c11b0d013f65bfe2778dfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:27:46 +0100 Subject: [PATCH 07/13] Release --- .github/workflows/github-actions-demo.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 160ed30..1833be7 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -28,3 +28,19 @@ jobs: with: name: alma-${{ matrix.target.name }} path: app/Alma + + release: + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: alma-windows + path: app/windows/ + - uses: actions/download-artifact@v3 + with: + name: alma-linux + path: app/linux/ + + - name: Display structure of downloaded files + run: ls -R + working-directory: app From 90ca560ad39bdce3d6cefc6aeb58b32a3ed66c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:29:24 +0100 Subject: [PATCH 08/13] Release depends on build --- .github/workflows/github-actions-demo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 1833be7..e9f1d81 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -30,6 +30,7 @@ jobs: path: app/Alma release: + needs: build runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 From 8f3f55c701d945e88c0843ae7461794fa1545a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:33:13 +0100 Subject: [PATCH 09/13] Output name for executable --- .github/workflows/github-actions-demo.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index e9f1d81..4c83a72 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -11,9 +11,11 @@ jobs: - runtime: win-x64 runner: windows-latest name: windows + outputname: Alma.exe - runtime: linux-x64 runner: ubuntu-latest name: linux + outputname: Alma steps: - uses: actions/checkout@v3 - name: Setup dotnet @@ -27,7 +29,7 @@ jobs: - uses: actions/upload-artifact@v3 with: name: alma-${{ matrix.target.name }} - path: app/Alma + path: app/${{ matrix.target.outputname }} release: needs: build From 5ae66d2388f62d1f50c3735c0f29022316e267dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 17:53:40 +0100 Subject: [PATCH 10/13] Release test --- .github/workflows/github-actions-demo.yml | 24 ++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 4c83a72..a732b90 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -36,14 +36,32 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 + name: Download Windows artifacts with: name: alma-windows path: app/windows/ - uses: actions/download-artifact@v3 + name: Download Linux artifacts with: name: alma-linux path: app/linux/ - - name: Display structure of downloaded files - run: ls -R - working-directory: app + - name: Create release directory + run: mkdir release + + - name: Copy windows executable + run: cp app/windows/Alma.exe release/alma.exe + + - name: Copy linux executable + run: cp app/linux/Alma release/alma-linux + + - uses: "marvinpinto/action-automatic-releases@latest" + name: Create release + with: + title: Test + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: latest + prerelease: false + draft: true + files: | + release/alma* From 12e65f2f4e8e9f32ba25205a13e5e58b43210169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 19:03:06 +0100 Subject: [PATCH 11/13] Add version scripts --- .../workflows/{github-actions-demo.yml => github-actions.yml} | 4 ++++ .scripts/versioning.ps1 | 0 .scripts/versioning.sh | 0 3 files changed, 4 insertions(+) rename .github/workflows/{github-actions-demo.yml => github-actions.yml} (91%) create mode 100644 .scripts/versioning.ps1 create mode 100755 .scripts/versioning.sh diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions.yml similarity index 91% rename from .github/workflows/github-actions-demo.yml rename to .github/workflows/github-actions.yml index a732b90..9933820 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions.yml @@ -12,16 +12,20 @@ jobs: runner: windows-latest name: windows outputname: Alma.exe + version_script: .scripts/versioning.ps1 - runtime: linux-x64 runner: ubuntu-latest name: linux outputname: Alma + version_script: .scripts/versioning.sh steps: - uses: actions/checkout@v3 - name: Setup dotnet uses: actions/setup-dotnet@v3 with: dotnet-version: '7.0.x' + - name: Patch version + run: ${{ matrix.target.version_script }} - name: Restore dependencies run: dotnet restore src/Alma - name: Build diff --git a/.scripts/versioning.ps1 b/.scripts/versioning.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/.scripts/versioning.sh b/.scripts/versioning.sh new file mode 100755 index 0000000..e69de29 From c1c11e9b4f5aeb4d319fc8aa36c69da32f6626be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 19:06:26 +0100 Subject: [PATCH 12/13] Print environment variables --- .scripts/versioning.ps1 | 1 + .scripts/versioning.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/.scripts/versioning.ps1 b/.scripts/versioning.ps1 index e69de29..c39b3f9 100644 --- a/.scripts/versioning.ps1 +++ b/.scripts/versioning.ps1 @@ -0,0 +1 @@ +gci env:\ \ No newline at end of file diff --git a/.scripts/versioning.sh b/.scripts/versioning.sh index e69de29..abefac4 100755 --- a/.scripts/versioning.sh +++ b/.scripts/versioning.sh @@ -0,0 +1 @@ +printenv \ No newline at end of file From 218a290e10ce1c51b4bdb6c0573561e4f23f0877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 19 Dec 2022 19:15:44 +0100 Subject: [PATCH 13/13] Get version from tag --- .github/workflows/github-actions.yml | 6 +++++- .scripts/versioning.ps1 | 16 +++++++++++++++- .scripts/versioning.sh | 17 ++++++++++++++++- src/Alma/Alma.csproj | 2 ++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 9933820..e55e0e2 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -1,6 +1,9 @@ name: Alma build -on: [push] +on: + push: + tags: + - "v*" jobs: build: @@ -26,6 +29,7 @@ jobs: dotnet-version: '7.0.x' - name: Patch version run: ${{ matrix.target.version_script }} + continue-on-error: true - name: Restore dependencies run: dotnet restore src/Alma - name: Build diff --git a/.scripts/versioning.ps1 b/.scripts/versioning.ps1 index c39b3f9..e44e44a 100644 --- a/.scripts/versioning.ps1 +++ b/.scripts/versioning.ps1 @@ -1 +1,15 @@ -gci env:\ \ No newline at end of file +gci env:\ + +if((Get-Content env:\GITHUB_REF_TYPE) -ne "tag") +{ + Return +} + +$version = (Get-Content env:\GITHUB_REF).Replace("refs/tags/v", "") +$git_sha = (Get-Content env:\GITHUB_SHA).Substring(0, 8) + +Write-Host $version +Write-Host $git_sha + +(Get-Content src\Alma\Alma.csproj).Replace("0.0.0", $version).Replace("development", $git_sha) | Set-Content src\Alma\Alma.csproj +Write-Host (Get-Content src\Alma\Alma.csproj) \ No newline at end of file diff --git a/.scripts/versioning.sh b/.scripts/versioning.sh index abefac4..a72aa94 100755 --- a/.scripts/versioning.sh +++ b/.scripts/versioning.sh @@ -1 +1,16 @@ -printenv \ No newline at end of file +printenv + +if [ ${GITHUB_REF_TYPE} != "tag" ]; then + exit 1 +fi + +version="${GITHUB_REF:11}" +git_hash="${GITHUB_SHA}" +echo $git_hash +git_hash=`expr substr $git_hash 1 8` + +echo $version +echo $git_hash + +sed -i "s/0.0.0/$version/g;s/development/$git_hash/g" src/Alma/Alma.csproj +cat src/Alma/Alma.csproj \ No newline at end of file diff --git a/src/Alma/Alma.csproj b/src/Alma/Alma.csproj index fe29fbe..f858dcc 100644 --- a/src/Alma/Alma.csproj +++ b/src/Alma/Alma.csproj @@ -14,6 +14,8 @@ net7.0 enable enable + 0.0.0 + development