Skip to content

1.0.2

1.0.2 #8

name: Publish Release
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
elixir-version: '1.15.2' # [Required] Define the Elixir version
otp-version: '26.0' # [Required] Define the Erlang/OTP version
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Restore _build cache
uses: actions/cache@v3
with:
path: _build
key: ${{ runner.os }}-build-${{ hashFiles('**/*.ex') }}
restore-keys: ${{ runner.os }}-build-
- name: Install dependencies
run: mix deps.get
- name: Update version in mix.exs
run: |
VERSION=${{ github.ref }}
VERSION=${VERSION#refs/tags/v}
sed -i "s/version: \".*\"/version: \"$VERSION\"/" mix.exs
- name: Commit changes
run: |
VERSION=${{ github.ref }}
VERSION=${VERSION#refs/tags/v}
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Update version in mix.exs to $VERSION" -a || true
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Delete existing tag
run: |
VERSION=${{ github.ref }}
VERSION=${VERSION#refs/tags/v}
git tag -d v$VERSION || true
- name: Push tag deletion
run: |
VERSION=${{ github.ref }}
VERSION=${VERSION#refs/tags/v}
git push origin :refs/tags/v$VERSION || true
- name: Tag the new commit
run: |
VERSION=${{ github.ref }}
VERSION=${VERSION#refs/tags/v}
git tag v$VERSION HEAD
- name: Push tags
run: git push --tags
- name: Publish to Hex
run: |
mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}