-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (64 loc) · 2.26 KB
/
elixir_publish_release.yml
File metadata and controls
73 lines (64 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: 🔩 Publish Release (Auto)
on:
workflow_call:
inputs:
branch:
type: string
default: main
description: "The branch to publish the release from."
publish-to-hex:
type: boolean
default: false
description: "Whether to publish the package to hex.pm"
elixir-version-file:
type: string
default: ".tool-versions"
description: "The Elixir Version File"
version-prefix:
type: string
default: "v"
description: "The prefix to use for version tags"
permissions:
contents: write
id-token: write
pull-requests: read
issues: read
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Current Version from mix.exs
id: new_version
shell: bash
run: |
VERSION=$(grep -o 'version: "[^"]*"' mix.exs | sed 's/version: "\(.*\)"/\1/')
VERSION_WITH_PREFIX="${{ inputs.version-prefix }}$VERSION"
echo "Current Version: $VERSION"
echo "Current Version with prefix: $VERSION_WITH_PREFIX"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version-with-prefix=$VERSION_WITH_PREFIX" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: release
uses: box-id/github-actions-oss/.github/actions/create-github-release@main
with:
branch: ${{ inputs.branch }}
version: ${{ steps.new_version.outputs.version }}
version-prefix: ${{ inputs.version-prefix }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Elixir
if: ${{ inputs.publish-to-hex && steps.release.outputs.version_has_changed == 'true' }}
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: ${{ inputs.elixir-version-file }}
- name: Install Dependencies
if: ${{ inputs.publish-to-hex && steps.release.outputs.version_has_changed == 'true' }}
run: mix deps.get
- name: Publish to Hex.pm
if: ${{ inputs.publish-to-hex && steps.release.outputs.version_has_changed == 'true' }}
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}