ghaction-upx/.github/workflows/release.yml

74 lines
2.6 KiB
YAML
Raw Normal View History

2020-01-17 01:46:36 -07:00
name: release
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
jobs:
release:
runs-on: ubuntu-latest
steps:
-
# https://github.com/actions/checkout
name: Checkout
uses: actions/checkout@v1
-
name: Prepare
id: prepare
run: |
TAG=${GITHUB_REF#refs/tags/}
MINOR=${TAG%.*}
MAJOR=${MINOR%.*}
echo ::set-output name=tag_name::${TAG}
echo ::set-output name=minor_tag::${MINOR}
echo ::set-output name=major_tag::${MAJOR}
echo ::set-output name=major_exists::$(git show-ref origin/releases/${MAJOR})
-
name: Set up Git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
-
name: Checkout releases/${{ steps.prepare.outputs.major_tag }} branch
run: |
git checkout -B releases/${{ steps.prepare.outputs.major_tag }}
if [ -n "${{ steps.prepare.outputs.major_exists }}" ]; then
git branch --set-upstream-to=origin/releases/${{ steps.prepare.outputs.major_tag }} releases/${{ steps.prepare.outputs.major_tag }}
fi
-
# https://github.com/actions/setup-node
name: Set up Node
uses: actions/setup-node@v1
-
name: NPM production deps
run: |
rm -rf node_modules
sed -i '/node_modules/d' .gitignore
npm install --production
-
name: Commit and push changes
run: |
git add --all
git status --short -uno
git commit -m 'Release ${{ steps.prepare.outputs.tag_name }}'
git show --stat-count=10 HEAD
git push -f origin releases/${{ steps.prepare.outputs.major_tag }}
-
name: Update ${{ steps.prepare.outputs.minor_tag }} tag
run: |
git push origin :refs/tags/${{ steps.prepare.outputs.minor_tag }}
git tag -fa ${{ steps.prepare.outputs.minor_tag }} -m "Release ${{ steps.prepare.outputs.tag_name }}"
git push origin ${{ steps.prepare.outputs.minor_tag }}
-
name: Update ${{ steps.prepare.outputs.major_tag }} tag
run: |
git push origin :refs/tags/${{ steps.prepare.outputs.major_tag }}
git tag -fa ${{ steps.prepare.outputs.major_tag }} -m "Release ${{ steps.prepare.outputs.tag_name }}"
git push origin ${{ steps.prepare.outputs.major_tag }}