diff --git a/.github/workflows/dappnode-update.yml b/.github/workflows/dappnode-update.yml new file mode 100644 index 0000000..c961a06 --- /dev/null +++ b/.github/workflows/dappnode-update.yml @@ -0,0 +1,51 @@ +name: Update Manifest file + +on: + repository_dispatch: + types: dappnode_update + +jobs: + dappnode-update: + name: Update Manifest file + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Cloning nethermind repo and fetching latest tag + run: | + git clone https://github.com/NethermindEth/nethermind.git + cd nethermind/ && git describe --tags > git-tag + - name: Updating package and Nethermind versions + run: | + GIT_TAG="$(tail nethermind/git-tag)" + VER="$(sed -n '3p' dappnode_package.json)" + VERSION=${VER:14:-2} + VERSION_UPDATED="$(./semver-update.sh patch $VERSION)" + sed -i "3s/.*/ \"version\": \"${VERSION_UPDATED}\",/" dappnode_package.json + sed -i "4s/.*/ \"upstreamVersion\": \"v${GIT_TAG}\",/" dappnode_package.json + sed -i "5s/.*/ image: 'nethermind.public.dappnode.eth:${VERSION_UPDATED}'/" docker-compose.yml + rm -rf nethermind/ + - name: Create Pull Request + uses: peter-evans/create-pull-request@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update manifest + body: | + Manifest file has been updated. + - Files included - dappnode_package.json + - Auto-generated by [create-pull-request][1] + + [1]: https://github.com/peter-evans/create-pull-request + title: 'Updating Manifest file' + labels: manifest + author-name: github-actions[bot] + author-email: 41898282+github-actions[bot]@users.noreply.github.com + committer-name: GitHub + committer-email: noreply@github.com + branch: manifest-update + branch-suffix: short-commit-hash + base: master + - name: Checking Outputs + run: | + echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}" + + diff --git a/.gitignore b/.gitignore index 2bd624b..426ff48 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -build_* +build_* \ No newline at end of file diff --git a/semver-update.sh b/semver-update.sh new file mode 100755 index 0000000..1a56cda --- /dev/null +++ b/semver-update.sh @@ -0,0 +1,37 @@ +#! /bin/bash + +RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)' + +step="$1" +if [ -z "$1" ] +then + step=patch +fi + +base="$2" +if [ -z "$2" ] +then + base=$(git tag 2>/dev/null| tail -n 1) + if [ -z "$base" ] + then + base=0.0.0 + fi +fi + +MAJOR=`echo $base | sed -e "s#$RE#\1#"` +MINOR=`echo $base | sed -e "s#$RE#\2#"` +PATCH=`echo $base | sed -e "s#$RE#\3#"` + +case "$step" in + major) + let MAJOR+=1 + ;; + minor) + let MINOR+=1 + ;; + patch) + let PATCH+=1 + ;; +esac + +echo "$MAJOR.$MINOR.$PATCH"