Skip to content

Publish

Publish #18

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to run the workflow on"
required: false
default: "main"
jobs:
version:
name: Calculate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.versioning.outputs.version-string }}
steps:
- uses: actions/checkout@v3
with:
ref: improve-auto-versioning
fetch-depth: 0
- name: Calculate semantic version
id: versioning
uses: bitshifted/[email protected]
with:
main_branch: main
create_tag: true
tag_prefix: "v"
publish:
name: Publish to Hex.pm
needs: version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Get calculated version
id: version
run: echo "version=${{ needs.version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Update version in mix.exs
env:
RELEASE_VERSION: ${{ needs.version.outputs.version }}
BRANCH_NAME: ${{ github.event.inputs.branch }}
run: |
# Checkout the branch
git checkout $BRANCH_NAME
# Configure Git user
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Update version in mix.exs
sed -i 's/version: ".*"/version: "'${RELEASE_VERSION#v}'"/g' mix.exs
sed -i 's/\{:shortcut_api_ex, ".*"\}/\{:shortcut_api_ex, "'"${RELEASE_VERSION#v}"'"\}/g' README.md
git add mix.exs
git commit -m "chore: Bump version to ${RELEASE_VERSION}"
git push origin $BRANCH_NAME
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ steps.version.outputs.version }}
git checkout ${{ github.ref }}
git tag $VERSION
git push origin $VERSION
gh release create $VERSION \
--title "Release $VERSION" \
--generate-notes
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.16.2"
otp-version: "26.2.5"
- name: Install dependencies
run: mix deps.get
- name: Generate docs
run: mix docs
- name: Publish to Hex.pm
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
# Remove the replace flag when proper versioning is in place
run: mix hex.publish --replace --yes