Skip to content

Merge branch 'main' of https://github.com/braybatista/Konex #251

Merge branch 'main' of https://github.com/braybatista/Konex

Merge branch 'main' of https://github.com/braybatista/Konex #251

Workflow file for this run

name: Release
on:
push:
branches: [ main ]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
jobs:
release:
environment: ACTIONS_ENV
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_2 }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
GITHUB_API_URL: ${{ vars.GH_API_URL }}
PUBLISH_ARTIFACT: ${{ vars.PUBLISH_ARTIFACT }}
DEBUG_MODE: ${{ vars.DEBUG_MODE }}
COMMIT_PUSH: ${{ vars.COMMIT_PUSH }}
ELIXIR_VERSION: ${{ vars.ELIXIR_VERSION }}
OTP_VERSION: ${{ vars.OTP_VERSION }}
SKIP_GIT_HOOKS: 'true'
SKIP_RELEASE: ${{ contains(github.event.head_commit.message, '[skip release]') || contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[release skip]') || contains(github.event.head_commit.message, '[ci skip]') }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
if: ${{ env.SKIP_RELEASE == 'false' }}
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Set up Elixir 1.14.3 and Otp 25
if: ${{ env.SKIP_RELEASE == 'false' }}
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Setup semantic-release
if: ${{ env.SKIP_RELEASE == 'false' }}
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/github conventional-changelog-eslint conventional-changelog-conventionalcommits conventional-changelog-angular -D
- name: Release
if: ${{ env.SKIP_RELEASE == 'false' }}
run: npx -p conventional-changelog-eslint -p conventional-changelog-conventionalcommits -p @semantic-release/changelog semantic-release
- name: Set variables From git tag command
if: ${{ env.SKIP_RELEASE == 'false' }}
run: |
echo "$VER"
echo "RELEASE_VERSION=$(git tag | sort --version-sort | tail -n1 | tr -d 'v')" >> $GITHUB_ENV
- name: Validate variables
if: ${{ env.SKIP_RELEASE == 'false' && env.DEBUG_MODE == 'true' }}
run: |
echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}"
echo "CONDITION RELEASE_VERSION != '';=${{ env.RELEASE_VERSION != '' }}"
echo "CONDITION PUBLISH_ARTIFACT == '';=${{ env.RELEASE_VERSION == '' }}"
echo "CONDITION PUBLISH_ARTIFACT == TRUE;=${{ env.PUBLISH_ARTIFACT == 'true' }}"
echo "CONDITION PUBLISH_ARTIFACT == FALSE;=${{ env.PUBLISH_ARTIFACT == 'false' }}"
echo "GITHUB_API_URL=${{ env.GITHUB_API_URL }}"
echo "PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT }}"
echo "COMMIT_PUSH=${{ env.COMMIT_PUSH }}"
echo "DEBUG_MODE=${{ env.DEBUG_MODE }}"
echo "COMMIT_LAST_MESSAGE: ${{ github.event.head_commit.message }}"
echo "SKIP_RELEASE: ${{ env.SKIP_RELEASE }}"
# COMMIT_PUSH steps
- name: Upgrade mix.exs
if: ${{ env.SKIP_RELEASE == 'false' && env.COMMIT_PUSH == 'true' }}
run: sed -i 's/@version \".*\"/@version "${{ env.RELEASE_VERSION }}"/g' mix.exs
working-directory: Elixir/Konex
- name: Commit And Push version
if: ${{ env.SKIP_RELEASE == 'false' && env.COMMIT_PUSH == 'true' }}
uses: github-actions-x/[email protected]
with:
github-token: ${{ env.GITHUB_TOKEN }}
push-branch: main
commit-message: '[skip release] [skip ci] Upgrade version to ${{ env.RELEASE_VERSION }}'
force-add: "true"
files: Elixir/Konex/mix.exs docs/CHANGELOG.md
name: Release Bot
email: [email protected]
# PUBLISH_ARTIFACT steps
- name: Install Mix dependencies
if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }}
run: mix deps.get && mix deps.compile
working-directory: Elixir/Konex
- name: Run Mix tests
if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }}
run: mix test
working-directory: Elixir/Konex
- name: Publish to HEX
if: ${{ env.SKIP_RELEASE == 'false' && env.PUBLISH_ARTIFACT == 'true' }}
run: mix hex.publish --replace --yes
working-directory: Elixir/Konex