fix: fixes bump version #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deployment | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "main" | |
paths: | |
- ".github/workflows/**" | |
- "jest.config.js" | |
- "package.json" | |
- "src/**" | |
- "tests/**" | |
- "tsconfig.json" | |
- "yarn.lock" | |
permissions: | |
issues: write | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
jobs: | |
continuous-deployment: | |
name: Deployment | |
runs-on: ubuntu-latest | |
steps: | |
- name: 👇 Checkout | |
uses: actions/checkout@v3 | |
- name: 🤹 Instal Deps | |
run: yarn install | |
- name: 🧪 Test | |
run: yarn test | |
- name: 🧱 Build | |
run: | | |
yarn build | |
if [ "$(git status --porcelain)" != "" ]; then | |
echo "GIT_IS_DIRTY=true" >> $GITHUB_ENV | |
else | |
echo "GIT_IS_DIRTY=false" >> $GITHUB_ENV | |
fi | |
- name: ✊ Bump Version | |
if: env.GIT_IS_DIRTY == 'true' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
CURRENT_BRANCH=${GITHUB_REF} | |
case $CURRENT_BRANCH in "refs/heads/"*) | |
CURRENT_BRANCH=$(echo "$CURRENT_BRANCH" | sed "s@refs/heads/@@") | |
esac | |
echo "machine github.com" > "$HOME/.netrc" | |
echo " login $GITHUB_ACTOR" >> "$HOME/.netrc" | |
echo " password ${{ github.token }}" >> "$HOME/.netrc" | |
echo "machine api.github.com" >> "$HOME/.netrc" | |
echo " login $GITHUB_ACTOR" >> "$HOME/.netrc" | |
echo " password ${{ github.token }}" >> "$HOME/.netrc" | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
LATEST_TAG=$(gh api repos/endaft/$(basename $PWD)/releases/latest --jq=.tag_name) | |
IFS=. read -r v1 v2 v3 <<< "${LATEST_TAG}" # split into (integer) components | |
v3=$((v3 + 1)) # do the math | |
LATEST_TAG="${v1}.${v2}.${v3}" | |
git commit -a -m "chore: updates dist js" | |
git tag -f "$LATEST_TAG" -m "Version $LATEST_TAG" | |
git tag -f latest -m "The latest version" | |
git push origin "$CURRENT_BRANCH:$CURRENT_BRANCH" --follow-tags --force --tags |