Merge pull request #267 from shocknet/feature/gh-version
Add version bump GitHub action
This commit is contained in:
commit
1ee8071862
1 changed files with 33 additions and 0 deletions
33
.github/workflows/version.yml
vendored
Normal file
33
.github/workflows/version.yml
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
on:
|
||||
release:
|
||||
types: [prereleased, released, published]
|
||||
|
||||
jobs:
|
||||
version-bump:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
persist-credentials: true
|
||||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
|
||||
- name: Get the last API TAG and current version in package.json
|
||||
run: |
|
||||
export RELEASE_TAG=$(curl -sS -X GET -G \
|
||||
-d max=300 \
|
||||
-H 'Accept: application/json' https://api.github.com/repos/shocknet/api/tags | jq -r '.[0].name')
|
||||
export API_TAG=$(cat ./package.json | jq -r '.version')
|
||||
echo $(if [ "$API_TAG" = "$RELEASE_TAG" ]; then echo "UPGRADEABLE=true"; else echo "UPGRADEABLE=false"; fi) >> $GITHUB_ENV
|
||||
|
||||
- name: Update and Commit files
|
||||
if: ${{ env.UPGRADEABLE == "true" }}
|
||||
run: |
|
||||
echo $(cat ./package.json | jq -r --arg API_TAG "$API_TAG" '.version = $API_TAG') > package.json
|
||||
git config --local user.email "actions@shock.network"
|
||||
git config --local user.name "Version Update Action"
|
||||
git commit -m "version upgraded to ${API_TAG}" -a
|
||||
- name: Push changes
|
||||
if: ${{ env.UPGRADEABLE == "true" }}
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: "master"
|
||||
Loading…
Add table
Add a link
Reference in a new issue