-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
7 changed files
with
699 additions
and
119 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 |
---|---|---|
@@ -0,0 +1,139 @@ | ||
name: Automatic Release | ||
on: | ||
schedule: | ||
- cron: 15 */8 * * * | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Check: | ||
outputs: | ||
json: ${{ steps.setVariables.outputs.json }} | ||
new_avail: ${{ steps.setVariables.outputs.new_avail }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get Latest Releases | ||
run: | | ||
# ----------------------------- # | ||
# --- get release version --- # | ||
# ----------------------------- # | ||
echo "< Fetching versions >" | ||
BRAVE="$(curl -s https://api.github.com/repos/brave/brave-browser/releases?per_page=5)" | ||
RELEASES="$(echo "$BRAVE" | jq -S -r '.[] | {name,tag_name}' | sed 's/ \\n\\n//g')" | ||
TAG_NAMES=$(echo "$RELEASES" | jq '.tag_name') | ||
# Only include latest version of release type to avoid conflict. | ||
# It's also pointless building outdated releases. | ||
LATEST_NIGHTLY=false | ||
LATEST_DEV=false | ||
LATEST_BETA=false | ||
LATEST_RELEASE=false | ||
OUT="{\"include\":[]}" | ||
# --------------------------------- # | ||
# --- check release existence --- # | ||
# --------------------------------- # | ||
echo "[ CHECKING ][ "$TAG_NAMES" ]" | ||
while read -r TAG; do | ||
# -- Skip existent releases -- | ||
ID="$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" | jq -r .id)" | ||
if [ "$ID" != "null" ]; then | ||
echo -e "Release ${TAG} already exists." | ||
else | ||
# -- check download links -- | ||
NAME="$(echo "$RELEASES" | jq --arg TAG "$TAG" '. | select(.tag_name==$TAG) | .name' | sed 's/\"//g')" | ||
EXISTS=$(echo "$BRAVE" | jq --arg TAG "$TAG" -r '.[] | select(.tag_name==$TAG) | | ||
.assets[].browser_download_url | contains("linux")' | sort | uniq) | ||
if [ "$EXISTS" = "false" ]; then | ||
echo "< Download links unavailable for ${NAME} >" | ||
else | ||
echo -e "< New Release: ${NAME} >" | ||
SKIP=true | ||
# -------------------------------- # | ||
# --- determine release type --- # | ||
# -------------------------------- # | ||
# -- Nightly | ||
if [[ $NAME =~ "Nightly" ]]; then | ||
BRAVE_PRERELEASE=true | ||
BRAVE_TYPE=nightly | ||
if [[ $LATEST_NIGHTLY == false ]]; then | ||
LATEST_NIGHTLY=true | ||
SKIP=false | ||
fi | ||
# -- Development | ||
elif [[ $NAME =~ "Dev" ]]; then | ||
BRAVE_PRERELEASE=true | ||
BRAVE_TYPE=dev | ||
if [[ $LATEST_DEV == false ]]; then | ||
LATEST_DEV=true | ||
SKIP=false | ||
fi | ||
# -- Beta | ||
elif [[ $NAME =~ "Beta" ]]; then | ||
BRAVE_PRERELEASE=true | ||
BRAVE_TYPE=beta | ||
if [[ $LATEST_BETA == false ]]; then | ||
LATEST_BETA=true | ||
SKIP=false | ||
fi | ||
# -- Release | ||
elif [[ $NAME =~ "Release" ]]; then | ||
BRAVE_PRERELEASE=false | ||
BRAVE_TYPE=stable | ||
if [[ $LATEST_RELEASE == false ]]; then | ||
LATEST_RELEASE=true | ||
SKIP=false | ||
fi | ||
fi | ||
# -- Add latest release to output -- | ||
if [[ $SKIP == false ]]; then | ||
OUT="$(echo $OUT | jq -c \ | ||
--arg TAG "$TAG" \ | ||
--arg TYPE "$BRAVE_TYPE" \ | ||
--arg PRERELEASE "$BRAVE_PRERELEASE" \ | ||
'.include |= . + | ||
[{ | ||
"tag": $TAG, | ||
"type": $TYPE, | ||
"prerelease": $PRERELEASE, | ||
}]')" | ||
fi | ||
fi | ||
fi | ||
done < <(echo "$RELEASES" | jq '.tag_name' | sed 's/\"//g') | ||
# -- Build releases, if they exist -- | ||
if [ "$OUT" == "{\"include\":[]}" ]; then | ||
echo "NEW_AVAILABLE=false" >> $GITHUB_ENV | ||
else | ||
echo "NEW_AVAILABLE=true" >> $GITHUB_ENV | ||
echo "OUT<<EOF" >> $GITHUB_ENV | ||
echo $OUT >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
fi | ||
- env: | ||
input_json: ${{ env.OUT }} | ||
input_avail: ${{ env.NEW_AVAILABLE }} | ||
id: setVariables | ||
run: | | ||
echo "json=$input_json" >> $GITHUB_OUTPUT | ||
echo "new_avail=$input_avail" >> $GITHUB_OUTPUT | ||
Build: | ||
needs: Check | ||
if: ${{ fromJson(needs.check.outputs.new_avail) }} | ||
uses: ./.github/workflows/release.yml | ||
with: | ||
input_json: ${{ needs.check.outputs.json }} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
name: Manual Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Brave version tag ("latest" or "vX.Y.Z")' | ||
required: true | ||
default: "latest" | ||
type: string | ||
rebuild: | ||
description: "Force rebuilding release" | ||
required: true | ||
default: false | ||
type: boolean | ||
|
||
jobs: | ||
Setup: | ||
outputs: | ||
json: ${{ steps.setVariables.outputs.json }} | ||
build_release: ${{ steps.setVariables.outputs.build_release }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Build | ||
continue-on-error: true | ||
run: | | ||
set -u | ||
# --------------------------- # | ||
# --- initial variables --- # | ||
# --------------------------- # | ||
INPUT_TAG=${{ inputs.tag }} | ||
INPUT_REBUILD=${{ inputs.rebuild }} | ||
# --------------------- # | ||
# --- get release --- # | ||
# --------------------- # | ||
TAG=${INPUT_TAG:-"latest"} # if no manual input, use "latest" by default | ||
REBUILD=${INPUT_REBUILD:-false} | ||
echo "< Fetching release >" | ||
if [ $TAG == "latest" ]; then | ||
BRAVE="$(curl -s https://api.github.com/repos/brave/brave-browser/releases?per_page=1 | jq -r '.[0]')" | ||
TAG="$(echo $BRAVE | jq '.tag_name' | sed 's/\"//g')" | ||
else | ||
BRAVE="$(curl -s "https://api.github.com/repos/brave/brave-browser/releases/tags/${TAG}")" | ||
fi | ||
# --------------------------------- # | ||
# --- check release existence --- # | ||
# --------------------------------- # | ||
ID="$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" | jq -r .id)" | ||
if [ "$ID" != "null" ] && [ $REBUILD = false ]; then | ||
echo -e "Release ${TAG} already exists." | ||
BUILD_RELEASE=false | ||
else | ||
NAME="$(echo $BRAVE | jq '.name' | sed 's/ \\n\\n//g')" | ||
EXISTS=$(echo "$BRAVE" | jq --arg TAG "$TAG" -r '. | select(.tag_name==$TAG) | | ||
.assets[].browser_download_url | contains("linux")' | sort | uniq) | ||
if [ "$EXISTS" = "false" ]; then | ||
echo "< Download links unavailable for ${NAME} >" | ||
BUILD_RELEASE=false | ||
else | ||
echo -e "< Building: ${NAME} >" | ||
# -------------------------------- # | ||
# --- determine release type --- # | ||
# -------------------------------- # | ||
if [[ $NAME =~ "Nightly" ]]; then | ||
BRAVE_PRERELEASE=true | ||
BRAVE_TYPE=nightly | ||
elif [[ $NAME =~ "Dev" ]]; then | ||
BRAVE_PRERELEASE=true | ||
BRAVE_TYPE=dev | ||
elif [[ $NAME =~ "Beta" ]]; then | ||
BRAVE_PRERELEASE=true | ||
BRAVE_TYPE=beta | ||
elif [[ $NAME =~ "Release" ]]; then | ||
BRAVE_PRERELEASE=false | ||
BRAVE_TYPE=stable | ||
fi | ||
BUILD_RELEASE=true | ||
fi | ||
fi | ||
if [ $BUILD_RELEASE = true ]; then | ||
# ------------------------------------- # | ||
# --- store environment variables --- # | ||
# ------------------------------------- # | ||
echo "TAG=$TAG" >> $GITHUB_ENV | ||
echo "TYPE=$BRAVE_TYPE" >> $GITHUB_ENV | ||
echo "PRE=$BRAVE_PRERELEASE" >> $GITHUB_ENV | ||
fi | ||
echo "BUILD_RELEASE=$BUILD_RELEASE" >> $GITHUB_ENV | ||
- env: | ||
tag: ${{ env.TAG }} | ||
type: ${{ env.TYPE }} | ||
pre: ${{ env.PRE }} | ||
build_release: ${{ env.BUILD_RELEASE }} | ||
id: setVariables | ||
run: | | ||
input_json="{\"include\":[{\"tag\": \"$tag\", \"type\": \"$type\", \"prerelease\": \"$pre\",}]}" | ||
echo "json=$input_json" >> $GITHUB_OUTPUT | ||
echo "build_release=$build_release" >> $GITHUB_OUTPUT | ||
Build: | ||
needs: Setup | ||
if: ${{ fromJson(needs.setup.outputs.build_release) }} | ||
uses: ./.github/workflows/release.yml | ||
with: | ||
input_json: ${{ needs.setup.outputs.json }} |
Oops, something went wrong.