-
Notifications
You must be signed in to change notification settings - Fork 19
92 lines (80 loc) · 2.67 KB
/
release.yml
File metadata and controls
92 lines (80 loc) · 2.67 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Release
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- master
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install semantic-release
run: |
npm install -g \
semantic-release@21
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: Check if release was created
id: check_release
run: |
# Get the current commit SHA
CURRENT_SHA=$(git rev-parse HEAD)
# Check if there's a tag pointing to this commit
if git describe --exact-match --tags $CURRENT_SHA 2>/dev/null; then
echo "release_created=true" >> $GITHUB_OUTPUT
echo "Release was created"
else
echo "release_created=false" >> $GITHUB_OUTPUT
echo "No release was created"
fi
- name: Set up Elixir
if: steps.check_release.outputs.release_created == 'true'
uses: erlef/setup-beam@v1
with:
elixir-version: '1.14.2'
otp-version: '25.1.1'
- name: Get latest release version
if: steps.check_release.outputs.release_created == 'true'
id: get_version
run: |
# Fetch all tags
git fetch --tags
# Get the latest tag
VERSION=$(git describe --tags --abbrev=0)
# Remove 'v' prefix if present
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Latest version: $VERSION"
- name: Update version in mix.exs
if: steps.check_release.outputs.release_created == 'true'
run: |
VERSION="${{ steps.get_version.outputs.version }}"
# Update the version in the project configuration
sed -i "s/^\s*version: \"[^\"]*\"/ version: \"$VERSION\"/" mix.exs
echo "Updated version to:"
cat mix.exs | grep "version:"
- name: Install dependencies
if: steps.check_release.outputs.release_created == 'true'
run: mix deps.get
- name: Publish to Hex.pm
if: steps.check_release.outputs.release_created == 'true'
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
run: mix hex.publish --yes