-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
105 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,119 @@ | ||
name: Create Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Windows x64 Release Build", "Linux amd64 Release Build"] | ||
types: | ||
- completed | ||
push: | ||
branches: [ release ] | ||
pull_request: | ||
branches: [ release ] | ||
|
||
jobs: | ||
release: | ||
if: github.ref_name == 'release' | ||
runs-on: ubuntu-latest | ||
|
||
runs-on: ubuntu-latest # You can specify other OS like windows-latest if needed | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
# Step 1: Poll for Cache Availability - name: Wait for Caches to Appear | ||
- name: Wait for Caches to Appear | ||
id: wait-for-cache | ||
run: | | ||
max_attempts=10 # Maximum number of attempts | ||
attempt=1 | ||
success=false | ||
while [ $attempt -le $max_attempts ]; do | ||
echo "Attempt $attempt: Checking for both caches..." | ||
# Check for both caches | ||
windows_cache=$(gh cache list --json key --jq ".[] | select(.key == \"windows-build-release-${GITHUB_SHA}\")") | ||
linux_cache=$(gh cache list --json key --jq ".[] | select(.key == \"linux-build-release-${GITHUB_SHA}\")") | ||
if [ -n "$windows_cache" ] && [ -n "$linux_cache" ]; then | ||
echo "Both caches found! Proceeding with build." | ||
success=true | ||
break | ||
else | ||
echo "One or both caches not found. Retrying in 30 seconds..." | ||
sleep 30 | ||
fi | ||
attempt=$(( attempt + 1 )) | ||
done | ||
if [ "$success" = false ]; then | ||
echo "Caches not available after $max_attempts attempts. Exiting..." | ||
exit 1 | ||
fi | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get the latest tag | ||
id: get_tag | ||
run: | | ||
latest_tag=$(git describe --tags --abbrev=0) | ||
echo "Latest tag: $latest_tag" | ||
# Extract version number (assuming tags follow semantic versioning) | ||
if [ -z "$latest_tag" ]; then | ||
echo "::set-output name=new_tag::v1.0.0" | ||
else | ||
major=$(echo $latest_tag | cut -d. -f1 | sed 's/v//') | ||
minor=$(echo $latest_tag | cut -d. -f2) | ||
patch=$(echo $latest_tag | cut -d. -f3) | ||
new_patch=$((patch + 1)) | ||
new_tag="v$major.$minor.$new_patch" | ||
echo "::set-output name=new_tag::$new_tag" | ||
fi | ||
shell: bash | ||
- name: Get the latest tag | ||
id: get_tag | ||
run: | | ||
latest_tag=$(git describe --tags --abbrev=0) | ||
echo "Latest tag: $latest_tag" | ||
# Extract version number (assuming tags follow semantic versioning) | ||
if [ -z "$latest_tag" ]; then | ||
echo "::set-output name=new_tag::v1.0.0" | ||
else | ||
major=$(echo $latest_tag | cut -d. -f1 | sed 's/v//') | ||
minor=$(echo $latest_tag | cut -d. -f2) | ||
patch=$(echo $latest_tag | cut -d. -f3) | ||
new_patch=$((patch + 1)) | ||
new_tag="v$major.$minor.$new_patch" | ||
echo "::set-output name=new_tag::$new_tag" | ||
fi | ||
shell: bash | ||
|
||
- name: Restore Windows x64 From Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./windows | ||
key: windows-app-build-${{ github.ref_name }}-${{ github.sha }} | ||
enableCrossOsArchive: true | ||
fail-on-cache-miss: true | ||
- name: Restore Windows x64 From Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./windows | ||
key: windows-app-build-${{ github.ref_name }}-${{ github.sha }} | ||
enableCrossOsArchive: true | ||
fail-on-cache-miss: true | ||
|
||
- name: Restore Linux amd64 From Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./linux | ||
key: linux-amd64-app-build-${{ github.ref_name }}-${{ github.sha }} | ||
enableCrossOsArchive: true | ||
fail-on-cache-miss: true | ||
- name: Restore Linux amd64 From Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./linux | ||
key: linux-amd64-app-build-${{ github.ref_name }}-${{ github.sha }} | ||
enableCrossOsArchive: true | ||
fail-on-cache-miss: true | ||
|
||
- name: Verify Restored Binaries | ||
run: | | ||
echo "Listing files in ./windows and ./linux:" | ||
ls -l ./windows | ||
ls -l ./linux | ||
- name: Verify Restored Binaries | ||
run: | | ||
echo "Listing files in ./windows and ./linux:" | ||
ls -l ./windows | ||
ls -l ./linux | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.get_tag.outputs.new_tag }} | ||
release_name: Tritime ${{ steps.get_tag.outputs.new_tag }} | ||
draft: false | ||
prerelease: false | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.get_tag.outputs.new_tag }} | ||
release_name: Tritime ${{ steps.get_tag.outputs.new_tag }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Windows Artifact to Release | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./ | ||
asset_name: tritime-win64.zip | ||
asset_content_type: application/zip | ||
- name: Upload Windows Artifact to Release | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./ | ||
asset_name: tritime-win64.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload Linux Artifact to Release | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./ | ||
asset_name: tritime-linux-amd64.tar.gz | ||
asset_content_type: application/tgz | ||
- name: Upload Linux Artifact to Release | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./ | ||
asset_name: tritime-linux-amd64.tar.gz | ||
asset_content_type: application/tgz |