Skip to content

Commit

Permalink
refactor(scripts): use exit code in scripts instead of echo (#1736)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Jan 14, 2023
1 parent 5108b1a commit 64697d3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/release-dry-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ jobs:
run: echo "RELEASE_TAG=v$(./script/semver.sh bump patch $(git describe --tags --abbrev=0))" >> $GITHUB_ENV
- name: git tag
run: git tag -a ${{ env.RELEASE_TAG }} -m ${{ env.RELEASE_TAG }}
- name: detect network from tag
run: echo "MAINNET=$(./script/mainnet-from-tag.sh ${{ env.RELEASE_TAG }})" >> $GITHUB_ENV
- run: echo "Building for MAINNET=${{ env.MAINNET }}"
- name: release dry-run
run: make release
19 changes: 15 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: release version
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: detect network from release
run: echo "MAINNET=$(./script/mainnet-from-tag.sh ${{ env.RELEASE_TAG }})" >> $GITHUB_ENV
run: echo "MAINNET=$(./script/mainnet-from-tag.sh ${{ env.RELEASE_TAG }} && echo 'true' && echo 'false')" >> $GITHUB_ENV
- run: echo "Building for MAINNET=${{ env.MAINNET }}"
- if: (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/mainnet/main')
name: release dry-run GORELEASER_SKIP_VALIDATE=true
Expand All @@ -54,13 +54,24 @@ jobs:
runs-on: ubuntu-latest
needs: [ goreleaser ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: release version
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: check if pre-release
id: check
run: |
echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: notify homebrew with new release
uses: benc-uk/workflow-dispatch@v121
is_prerelease=$(./script/is_prerelease.sh ${{ env.RELEASE_TAG }}; echo $?)
is_mainnet=$(./script/mainnet-from-tag.sh ${{ env.RELEASE_TAG }}; echo $?)
echo "is_prerelease=${is_prerelease}" >> $GITHUB_OUTPUT
echo "is_mainnet=${is_mainnet}" >> $GITHUB_OUTPUT
- name: notify homebrew with a new release
if: contains(steps.check.outputs.is_mainnet, '0') && contains(steps.check.outputs.is_prerelease, '1')
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.GORELEASER_ACCESS_TOKEN }}
repo: akash-network/homebrew-tap
ref: refs/heads/master
workflow: akash
inputs: '{"tag": "${{ env.RELEASE_TAG }}"}'
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ GIT_HEAD_COMMIT_SHORT := $(shell git rev-parse --short HEAD)
GIT_HEAD_ABBREV := $(shell git rev-parse --abbrev-ref HEAD)

RELEASE_TAG ?= $(shell git describe --tags --abbrev=0)
IS_PREREL := $(shell $(ROOT_DIR)/script/is_prerelease.sh "$(RELEASE_TAG)")
IS_MAINNET := $(shell $(ROOT_DIR)/script/mainnet-from-tag.sh "$(RELEASE_TAG)")
IS_PREREL := $(shell $(ROOT_DIR)/script/is_prerelease.sh "$(RELEASE_TAG)" && echo "true" || echo "false")
IS_MAINNET := $(shell $(ROOT_DIR)/script/mainnet-from-tag.sh "$(RELEASE_TAG)" && echo "true" || echo "false")
IS_STABLE ?= false

GO_LINKMODE ?= external
Expand Down
4 changes: 2 additions & 2 deletions script/genchangelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ fi
to_tag=$1

# s1
is_mainnet=$("${SCRIPT_DIR}"/mainnet-from-tag.sh "$to_tag")
if [[ $is_mainnet == false ]]; then
# shellcheck disable=SC1073
if ! "${SCRIPT_DIR}"/mainnet-from-tag.sh "$to_tag" ; then
version_rel="^[v|V]?(0|[1-9][0-9]*)\\.(\\d*[13579])\\.(0|[1-9][0-9]*)$"
version_prerel="^[v|V]?(0|[1-9][0-9]*)\\.(\\d*[13579])\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
else
Expand Down
2 changes: 1 addition & 1 deletion script/is_prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ if [[ $# -ne 1 ]]; then
exit 1
fi

[[ -n $("${SCRIPT_DIR}"/semver.sh get prerel "$1") ]] && echo true || echo false
[[ -n $("${SCRIPT_DIR}"/semver.sh get prerel "$1") ]] && exit 0 || exit 1
2 changes: 1 addition & 1 deletion script/mainnet-from-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ if [[ $# -ne 1 ]]; then
exit 1
fi

[[ $(($("${SCRIPT_DIR}"/semver.sh get minor "$1") % 2)) -eq 0 ]] && echo true || echo false
[[ $(($("${SCRIPT_DIR}"/semver.sh get minor "$1") % 2)) -eq 0 ]] && exit 0 && exit 1

0 comments on commit 64697d3

Please sign in to comment.