Skip to content

Commit

Permalink
feat: implement rolling builds
Browse files Browse the repository at this point in the history
This diff modifies all the github actions that produce assets to
publish on a release called rolling when we are not building a tag.

If everything goes as planned, we should be able to provide
people with automatically generated fresh binaries for testing.

See ooni/probe#2249
  • Loading branch information
bassosimone committed Aug 30, 2022
1 parent d1b172f commit 6c11085
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 78 deletions.
37 changes: 11 additions & 26 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jobs:
- run: make MOBILE/android

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./MOBILE/android/oonimkall.aar \
./MOBILE/android/oonimkall-sources.jar \
./MOBILE/android/oonimkall.pom
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./MOBILE/android/oonimkall.aar \
./MOBILE/android/oonimkall-sources.jar \
./MOBILE/android/oonimkall.pom
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -76,11 +73,8 @@ jobs:
- run: make CLI/android-386

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/miniooni-android-386 \
./CLI/ooniprobe-android-386
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./CLI/miniooni-android-386 \
./CLI/ooniprobe-android-386
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -112,11 +106,8 @@ jobs:
- run: make CLI/android-amd64

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/miniooni-android-amd64 \
./CLI/ooniprobe-android-amd64
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./CLI/miniooni-android-amd64 \
./CLI/ooniprobe-android-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -148,11 +139,8 @@ jobs:
- run: make CLI/android-arm

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/miniooni-android-arm \
./CLI/ooniprobe-android-arm
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./CLI/miniooni-android-arm \
./CLI/ooniprobe-android-arm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -184,10 +172,7 @@ jobs:
- run: make CLI/android-arm64

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/miniooni-android-arm64 \
./CLI/ooniprobe-android-arm64
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./CLI/miniooni-android-arm64 \
./CLI/ooniprobe-android-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 2 additions & 5 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ jobs:
- run: make EXPECTED_XCODE_VERSION=12.4 MOBILE/ios

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./MOBILE/ios/oonimkall.xcframework.zip \
./MOBILE/ios/oonimkall.podspec
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./MOBILE/ios/oonimkall.xcframework.zip \
./MOBILE/ios/oonimkall.podspec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 5 additions & 25 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ jobs:
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
- run: make CLI/linux-static-386
- run: ./E2E/ooniprobe.sh ./CLI/ooniprobe-linux-386
- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/ooniprobe-linux-386 ./CLI/miniooni-linux-386
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- run: ./script/ghpublish.bash ./CLI/ooniprobe-linux-386 ./CLI/miniooni-linux-386
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -50,11 +46,7 @@ jobs:
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
- run: make CLI/linux-static-amd64
- run: ./E2E/ooniprobe.sh ./CLI/ooniprobe-linux-amd64
- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/ooniprobe-linux-amd64 ./CLI/miniooni-linux-amd64
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- run: ./script/ghpublish.bash ./CLI/ooniprobe-linux-amd64 ./CLI/miniooni-linux-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -76,11 +68,7 @@ jobs:
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
- run: make CLI/linux-static-armv6
- run: ./E2E/ooniprobe.sh ./CLI/ooniprobe-linux-armv6
- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/ooniprobe-linux-armv6 ./CLI/miniooni-linux-armv6
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- run: ./script/ghpublish.bash ./CLI/ooniprobe-linux-armv6 ./CLI/miniooni-linux-armv6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -102,11 +90,7 @@ jobs:
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
- run: make CLI/linux-static-armv7
- run: ./E2E/ooniprobe.sh ./CLI/ooniprobe-linux-armv7
- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/ooniprobe-linux-armv7 ./CLI/miniooni-linux-armv7
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- run: ./script/ghpublish.bash ./CLI/ooniprobe-linux-armv7 ./CLI/miniooni-linux-armv7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -128,10 +112,6 @@ jobs:
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
- run: make CLI/linux-static-arm64
- run: ./E2E/ooniprobe.sh ./CLI/ooniprobe-linux-arm64
- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/ooniprobe-linux-arm64 ./CLI/miniooni-linux-arm64
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- run: ./script/ghpublish.bash ./CLI/ooniprobe-linux-arm64 ./CLI/miniooni-linux-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 4 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jobs:
- run: ./E2E/ooniprobe.sh ./CLI/ooniprobe-darwin-amd64

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/ooniprobe-darwin-amd64 \
./CLI/ooniprobe-darwin-arm64 \
./CLI/miniooni-darwin-amd64 \
./CLI/miniooni-darwin-arm64
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ./CLI/ooniprobe-darwin-amd64 \
./CLI/ooniprobe-darwin-arm64 \
./CLI/miniooni-darwin-amd64 \
./CLI/miniooni-darwin-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 1 addition & 5 deletions .github/workflows/oohelperd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ jobs:
- name: build oohelperd binary
run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./CLI/oohelperd-linux-amd64 -v -tags netgo -ldflags="-s -w -extldflags -static" ./internal/cmd/oohelperd

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ./CLI/oohelperd-linux-amd64
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- run: ./script/ghpublish.bash ./CLI/oohelperd-linux-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 1 addition & 3 deletions .github/workflows/tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
tar czf ooni-probe-cli-${VERSION}.tar.gz --transform "s,^,ooni-probe-cli-${VERSION}/," *
- name: Upload release tarball
run: |
gh release create -p $GITHUB_REF_NAME --target $GITHUB_SHA || true
gh release upload $GITHUB_REF_NAME --clobber ooni-probe-cli-*.tar.gz
run: ./script/ghpublish.bash ooni-probe-cli-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 4 additions & 7 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,9 @@ jobs:
name: miniooni-windows-386.exe

- run: |
tag=$(echo $GITHUB_REF | sed 's|refs/tags/||g')
gh release create -p $tag --target $GITHUB_SHA || true
gh release upload $tag --clobber ooniprobe-windows-386.exe \
ooniprobe-windows-amd64.exe \
miniooni-windows-386.exe
miniooni-windows-amd64.exe
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
./script/ghpublish.bash ooniprobe-windows-386.exe \
ooniprobe-windows-amd64.exe \
miniooni-windows-386.exe
miniooni-windows-amd64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions script/ghpublish.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail

# 1. obtain the github ref of this action run
__ref=${GITHUB_REF:-}

if [[ $__ref == "" ]]; then
echo "FATAL: missing github ref" 1>&2
exit 1
fi

# 2. determine whether to publish to a release or to rolling
if [[ $__ref =~ ^refs/tags/v ]]; then
__tag=${__ref#refs/tags/}
else
__tag=rolling
fi

set -x

# 3. create the release as a pre-release unless it already exists
gh release create -p $__tag --target $GITHUB_SHA || true

# 4. publish all the assets passed as arguments to the target release
gh release upload $__tag --clobber "$@"

0 comments on commit 6c11085

Please sign in to comment.