Pass release tag as env var in version action
This commit is contained in:
parent
f66b60be2c
commit
0aa43760af
1 changed files with 29 additions and 26 deletions
19
.github/workflows/version.yml
vendored
19
.github/workflows/version.yml
vendored
|
|
@ -1,6 +1,8 @@
|
||||||
|
name: Bump "package.json" Version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [prereleased, released, published]
|
types: [prereleased, released]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
version-bump:
|
version-bump:
|
||||||
|
|
@ -8,23 +10,24 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
with:
|
with:
|
||||||
persist-credentials: true
|
persist-credentials: false
|
||||||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
|
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
|
- name: Get the last API TAG and current version in package.json
|
||||||
run: |
|
run: |
|
||||||
export RELEASE_TAG=$(curl -sS -X GET -G \
|
export RELEASE_TAG=$(git describe --tags --abbrev=0) && \
|
||||||
-d max=300 \
|
echo "VERSION=${RELEASE_TAG}" >> $GITHUB_ENV
|
||||||
-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')
|
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
|
|
||||||
|
echo $(if [ "$API_TAG" = "$RELEASE_TAG" ]; then echo "UPGRADEABLE=false"; else echo "UPGRADEABLE=true"; fi) >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Update and Commit files
|
- name: Update and Commit files
|
||||||
if: ${{ env.UPGRADEABLE == 'true' }}
|
if: ${{ env.UPGRADEABLE == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
echo $(cat ./package.json | jq -r --arg API_TAG "$API_TAG" '.version = $API_TAG') > package.json
|
cat ./package.json | jq -r --arg API_TAG "${{ env.VERSION }}" '.version = $API_TAG' | tee a.json && mv a.json package.json
|
||||||
git config --local user.email "actions@shock.network"
|
git config --local user.email "actions@shock.network"
|
||||||
git config --local user.name "Version Update Action"
|
git config --local user.name "Version Update Action"
|
||||||
git commit -m "version upgraded to ${API_TAG}" -a
|
git commit -m "version upgraded to ${{ env.VERSION }}" -a
|
||||||
- name: Push changes
|
- name: Push changes
|
||||||
if: ${{ env.UPGRADEABLE == 'true' }}
|
if: ${{ env.UPGRADEABLE == 'true' }}
|
||||||
uses: ad-m/github-push-action@master
|
uses: ad-m/github-push-action@master
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue