Publish Release #3
Workflow file for this run
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: 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: | | |
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 | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
- name: Delete existing tag | |
run: git tag -d v$VERSION || true | |
- name: Push tag deletion | |
run: git push origin :refs/tags/v$VERSION || true | |
- name: Tag the new commit | |
run: 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 }} |