Skip to content

Commit

Permalink
Deploy rolling release assets
Browse files Browse the repository at this point in the history
  • Loading branch information
albertziegenhagel committed Oct 22, 2023
1 parent 2c143e4 commit b70e14b
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 1 deletion.
118 changes: 118 additions & 0 deletions .github/workflows/deploy-head.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: "Deploy head"

on:
workflow_call

permissions:
contents: write
deployments: write

jobs:
check:
name: "Check skip"

runs-on: ubuntu-latest
outputs:
is_newer: ${{ steps.step1.outputs.result }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check agains head
id: step1
shell: pwsh
run: |
git merge-base --is-ancestor refs/tags/head ${{ github.sha }}
echo "Result: $LASTEXITCODE"
if($LASTEXITCODE -eq 0) {
"result=1" | Out-File -Path $env:GITHUB_OUTPUT -Append
}
elseif($LASTEXITCODE -eq 1) {
"result=0" | Out-File -Path $env:GITHUB_OUTPUT -Append
exit 0
}
tag:
name: "Update tag"

runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.is_newer == 1

steps:
- uses: actions/checkout@v3

- name: Update head tag
run: |
git push --delete origin head
git tag head
git push origin head
assets:
name: "Upload assets"

runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.is_newer == 1

steps:
- name: Download build artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci.yml
workflow_conclusion: in_progress
branch: ${{ github.ref_name }}
name: childdebugger-win32-x64
check_artifacts: true
search_artifacts: true

- name: Upload release asset
shell: pwsh
run: |
$assetId = curl -L `
-H "Accept: application/vnd.github+json" `
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" `
-H "X-GitHub-Api-Version: 2022-11-28" `
https://api.github.com/repos/albertziegenhagel/childdebugger-concord/releases/126145941/assets | `
ConvertFrom-Json | `
Where-Object -Property name -Value "childdebugger-win32-x64.vsix" -EQ | `
Select-Object -Expand id
if($assetId) {
curl -L `
-X DELETE `
-H "Accept: application/vnd.github+json" `
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"`
-H "X-GitHub-Api-Version: 2022-11-28" `
https://api.github.com/repos/albertziegenhagel/childdebugger-concord/releases/assets/$assetId
}
curl -i -X POST `
-H "Accept: application/vnd.github+json" `
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" `
-H "X-GitHub-Api-Version: 2022-11-28" `
-H "Content-Type: application/zip" `
--data-binary "@childdebugger-win32-x64.vsix" `
"https://uploads.github.com/repos/albertziegenhagel/childdebugger-concord/releases/126145941/assets?name=childdebugger-win32-x64.vsix"
publish:
name: "Puplish"

runs-on: ubuntu-latest
needs:
- tag
- assets

steps:
- uses: actions/checkout@v3

- name: Mark release as non-draft
run: |
curl -L -X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/albertziegenhagel/childdebugger-concord/releases/126145941" \
-d '{"draft":false}'
13 changes: 12 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Package
on:
push

permissions:
contents: write
deployments: write

jobs:
package:
runs-on: windows-latest
Expand Down Expand Up @@ -35,10 +39,17 @@ jobs:
- name: Package
run: |
rm concord-extension/childdebugger-concord-x86_64-windows.zip
vsce package --target win32-x64
vsce package --target win32-x64 --pre-release
mv childdebugger-win32-x64-*.vsix childdebugger-win32-x64.vsix
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: childdebugger-win32-x64
path: ${{ github.workspace }}/*.vsix

deploy-head:
name: "Deploy head"
needs: package
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/deploy-head.yml

0 comments on commit b70e14b

Please sign in to comment.