validate VERSION-TAG.env 2 #138
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: Release | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ created ] | |
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 }} | |
RELEASE_VERSION: ${{ vars.RELEASE_VERSION }} | |
DEBUG_MODE: ${{ vars.DEBUG_MODE }} | |
COMMIT_PUSH: ${{ vars.COMMIT_PUSH }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Set up Elixir 1.14.3 and Otp 25 | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.14.3' | |
otp-version: '25' | |
- name: setup semantic-release | |
run: npm install -g semantic-release @semantic-release/exec @semantic-release/changelog @semantic-release/github -D | |
- name: release | |
run: npx -p @semantic-release/changelog -p @semantic-release/exec semantic-release | |
#testing | |
- name: Check for file VERSION-TAG.env | |
run: | | |
ls -l | |
echo "VERSION-TAG.env: |${{ hashFiles('VERSION-TAG.env') }}|" | |
echo "VERSION-TAG.env2: |${{ hashFiles('VERSION-TAG.env2') }}|" | |
echo "script.sql: |${{ hashFiles('script.sql') }}|" | |
echo "FILE_VERSION_TAG_EXISTS=true" >> $GITHUB_ENV | |
- name: Validate conditions | |
if: ${{ env.DEBUG_MODE == 'true' }} | |
run: | | |
echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" | |
echo "PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT }}" | |
echo "CONDITION not EQ RELEASE_VERSION=${{ env.RELEASE_VERSION != '' }}" | |
echo "CONDITION EQ RELEASE_VERSION=${{ env.RELEASE_VERSION == '' }}" | |
echo "CONDITION TRUE PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT == 'true' }}" | |
echo "CONDITION FALSE PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT == 'false' }}" | |
echo "GITHUB_API_URL=${{ env.GITHUB_API_URL }}" | |
echo "COMMIT_PUSH=${{ env.COMMIT_PUSH }}" | |
echo "DEBUG_MODE=${{ env.DEBUG_MODE }}" | |
echo "FILE_VERSION_TAG_EXISTS=${{ env.FILE_VERSION_TAG_EXISTS }}" | |
- name: Set variables From VERSION-TAG.env | |
if: ${{ env.FILE_VERSION_TAG_EXISTS == 'true' }} | |
run: | | |
VER=$(cat VERSION-TAG.env) | |
echo "$VER" | |
echo "RELEASE_VERSION=$VER" >> $GITHUB_ENV | |
- name: Install Mix dependencies | |
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) && ( env.RELEASE_VERSION != '' ) }} | |
run: mix deps.get && mix deps.compile | |
working-directory: Elixir/Konex | |
env: | |
SKIP_GIT_HOOKS: 'true' | |
- name: Run Mix tests | |
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) && ( env.RELEASE_VERSION != '' ) }} | |
run: mix test | |
working-directory: Elixir/Konex | |
- name: Upgrade mix.exs | |
if: ${{ ( ( env.COMMIT_PUSH == 'true' ) && ( env.RELEASE_VERSION != '' ) ) || ( ( env.PUBLISH_ARTIFACT == 'true' ) && ( env.RELEASE_VERSION != '' ) ) }} | |
run: sed -i 's/@version \".*\"/@version "${{ env.RELEASE_VERSION }}"/g' mix.exs | |
working-directory: Elixir/Konex | |
# testing | |
- name: Commit And Push version | |
if: ${{ ( ( env.COMMIT_PUSH == 'true' ) && ( env.RELEASE_VERSION != '' ) ) || ( ( env.PUBLISH_ARTIFACT == 'true' ) && ( env.RELEASE_VERSION != '' ) ) }} | |
uses: github-actions-x/[email protected] | |
with: | |
github-token: ${{ env.GITHUB_TOKEN }} | |
push-branch: main | |
commit-message: '[skip release] Upgrade version to ${{ env.RELEASE_VERSION }}' | |
force-add: "true" | |
files: mix.exs | |
name: Release Bot | |
email: [email protected] | |
- name: Publish to HEX | |
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) && ( env.RELEASE_VERSION != '' ) }} | |
run: mix hex.publish --replace --yes | |
working-directory: Elixir/Konex | |
env: | |
HEX_API_KEY: ${{ secrets.HEX_API_KEY }} |