Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cec60d324b | ||
|
|
f10feef23a |
19
.github/workflows/android.yml
vendored
19
.github/workflows/android.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- github-action-test
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@ -17,6 +18,22 @@ jobs:
|
|||||||
- name: checkout sources
|
- name: checkout sources
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: atomically create or retrieve the build number
|
||||||
|
id: build_nr
|
||||||
|
run: |
|
||||||
|
cd .. # check out parallel to subsurface sources
|
||||||
|
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
|
||||||
|
# the clone followed by the pointless push should verify that the password is stored in the config
|
||||||
|
# that way the script doesn't need the password
|
||||||
|
git clone -b main https://github.com/subsurface/nightly-builds
|
||||||
|
cd nightly-builds
|
||||||
|
git remote set-url origin "$url"
|
||||||
|
git push origin main
|
||||||
|
cd ..
|
||||||
|
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
|
||||||
|
latest=$(<nightly-builds/latest-subsurface-buildnumber)
|
||||||
|
echo "latest=$latest" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: create release name
|
- name: create release name
|
||||||
id: tag
|
id: tag
|
||||||
run: |
|
run: |
|
||||||
@ -60,7 +77,7 @@ jobs:
|
|||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ steps.date.outputs.today }}.${{ github.run_number }}
|
tag_name: v${{ steps.date.outputs.today }}.${{ steps.build_nr.outputs.latest }}
|
||||||
repository: subsurface/nightly-builds
|
repository: subsurface/nightly-builds
|
||||||
token: ${{ secrets.NIGHTLY_BUILDS }}
|
token: ${{ secrets.NIGHTLY_BUILDS }}
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|||||||
18
.github/workflows/mac.yml
vendored
18
.github/workflows/mac.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- github-action-test
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@ -13,6 +14,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: checkout sources
|
- name: checkout sources
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
- name: atomically create or retrieve the build number
|
||||||
|
id: build_nr
|
||||||
|
run: |
|
||||||
|
cd .. # check out parallel to subsurface sources
|
||||||
|
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
|
||||||
|
# the clone followed by the pointless push should verify that the password is stored in the config
|
||||||
|
# that way the script doesn't need the password
|
||||||
|
git clone -b main https://github.com/subsurface/nightly-builds
|
||||||
|
cd nightly-builds
|
||||||
|
git remote set-url origin "$url"
|
||||||
|
git push origin main
|
||||||
|
cd ..
|
||||||
|
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
|
||||||
|
latest=$(<nightly-builds/latest-subsurface-buildnumber)
|
||||||
|
echo "latest=$latest" >> $GITHUB_OUTPUT
|
||||||
- name: setup Homebrew
|
- name: setup Homebrew
|
||||||
run: brew install hidapi libxslt libjpg libmtp create-dmg confuse
|
run: brew install hidapi libxslt libjpg libmtp create-dmg confuse
|
||||||
- name: set our Qt build
|
- name: set our Qt build
|
||||||
@ -49,7 +65,7 @@ jobs:
|
|||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ steps.date.outputs.today }}.${{ github.run_number }}
|
tag_name: v${{ steps.date.outputs.today }}.${{ steps.build_nr.outputs.latest }}
|
||||||
repository: subsurface/nightly-builds
|
repository: subsurface/nightly-builds
|
||||||
token: ${{ secrets.NIGHTLY_BUILDS }}
|
token: ${{ secrets.NIGHTLY_BUILDS }}
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|||||||
19
.github/workflows/windows.yml
vendored
19
.github/workflows/windows.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- github-action-test
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@ -17,6 +18,22 @@ jobs:
|
|||||||
- name: checkout sources
|
- name: checkout sources
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: atomically create or retrieve the build number
|
||||||
|
id: build_nr
|
||||||
|
run: |
|
||||||
|
cd .. # check out parallel to subsurface sources
|
||||||
|
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
|
||||||
|
# the clone followed by the pointless push should verify that the password is stored in the config
|
||||||
|
# that way the script doesn't need the password
|
||||||
|
git clone -b main https://github.com/subsurface/nightly-builds
|
||||||
|
cd nightly-builds
|
||||||
|
git remote set-url origin "$url"
|
||||||
|
git push origin main
|
||||||
|
cd ..
|
||||||
|
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
|
||||||
|
latest=$(<nightly-builds/latest-subsurface-buildnumber)
|
||||||
|
echo "latest=$latest" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: create release name
|
- name: create release name
|
||||||
id: tag
|
id: tag
|
||||||
run: |
|
run: |
|
||||||
@ -67,7 +84,7 @@ jobs:
|
|||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ steps.date.outputs.today }}.${{ github.run_number }}
|
tag_name: v${{ steps.date.outputs.today }}.${{ steps.build_nr.outputs.latest }}
|
||||||
repository: subsurface/nightly-builds
|
repository: subsurface/nightly-builds
|
||||||
token: ${{ secrets.NIGHTLY_BUILDS }}
|
token: ${{ secrets.NIGHTLY_BUILDS }}
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|||||||
60
scripts/get-or-create-build-nr.sh
Normal file
60
scripts/get-or-create-build-nr.sh
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# this is comically complicated - why does GitHub not have a monotonic number
|
||||||
|
# that tracks how many times any action was kicked off? Or an atomic way to update a variable?
|
||||||
|
# So we use the fact that git itself does a great job of preventing us from overwriting an
|
||||||
|
# existing branch and abuse that to create atomicity
|
||||||
|
|
||||||
|
SHA_BRANCH="branch-for-$1"
|
||||||
|
|
||||||
|
# first - make sure git is configured so we can do stuff
|
||||||
|
git config --global user.email "ci@subsurface-divelog.org"
|
||||||
|
git config --global user.name "Subsurface CI"
|
||||||
|
|
||||||
|
# next, clone the release repo
|
||||||
|
[ -d nightly-builds ] || git clone https://github.com/subsurface/nightly-builds
|
||||||
|
cd nightly-builds
|
||||||
|
|
||||||
|
# this is from the main branch, so this should be the PREVIOUS build number
|
||||||
|
latest=$(<latest-subsurface-buildnumber)
|
||||||
|
|
||||||
|
# now let's see if a branch for the current SHA exists
|
||||||
|
if git checkout $SHA_BRANCH
|
||||||
|
then
|
||||||
|
# one of the other workflows created a release number already
|
||||||
|
latest=$(<latest-subsurface-buildnumber)
|
||||||
|
else
|
||||||
|
# this is almost certainly a race between the different workflow files
|
||||||
|
# the main branch should have held the previous release number
|
||||||
|
# increment by one and write as new build number into the named branch
|
||||||
|
latest=$((latest+1))
|
||||||
|
git checkout -b $SHA_BRANCH
|
||||||
|
echo $latest > latest-subsurface-buildnumber
|
||||||
|
git commit -a -m "record build number for this SHA"
|
||||||
|
|
||||||
|
# now comes the moment of truth - are we the first one?
|
||||||
|
# the push will succeed for exactly one of the workflows
|
||||||
|
if git push https://github.com/subsurface/nightly-builds $SHA_BRANCH
|
||||||
|
then
|
||||||
|
# yay - we win! now let's make sure that we remember this number for next time
|
||||||
|
git checkout main
|
||||||
|
echo $latest > latest-subsurface-buildnumber
|
||||||
|
git commit -a -m "record latest build number in main branch"
|
||||||
|
if ! git push https://github.com/subsurface/nightly-builds main
|
||||||
|
then
|
||||||
|
echo "push to main failed - we'll lose monotonic property"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# someone else was faster - get the number they wrote
|
||||||
|
git checkout main
|
||||||
|
git branch -D $SHA_BRANCH
|
||||||
|
if ! git checkout -b $SHA_BRANCH
|
||||||
|
then
|
||||||
|
echo "push to $SHA_BRANCH failed, but switching to it failed as well"
|
||||||
|
exit -2
|
||||||
|
fi
|
||||||
|
latest=$(<latest-subsurface-buildnumber)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# if we get here, we have the next build number - wow that was weird.
|
||||||
|
echo "Build number is $latest"
|
||||||
Loading…
x
Reference in New Issue
Block a user