-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (86 loc) · 3.6 KB
/
template-main.yml
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
93
94
95
96
97
98
99
100
101
102
103
104
name: Release
on:
push:
branches: [ main ]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
jobs:
release:
environment: ACTIONS_ENV
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
GITHUB_API_URL: ${{ vars.GH_API_URL }}
PUBLISH_ARTIFACT: ${{ vars.PUBLISH_ARTIFACT }}
DEBUG_MODE: ${{ vars.DEBUG_MODE }}
COMMIT_PUSH: ${{ vars.COMMIT_PUSH }}
ELIXIR_VERSION: ${{ vars.ELIXIR_VERSION }}
OTP_VERSION: ${{ vars.OTP_VERSION }}
SKIP_GIT_HOOKS: 'true'
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Set up Elixir ${{ env.ELIXIR_VERSION }} and Otp ${{ env.OTP_VERSION }}
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: setup semantic-release
run: npm install -g semantic-release @semantic-release/commit-analyzer @semantic-release/changelog @semantic-release/github -D
- name: release
run: npx -p @semantic-release/commit-analyzer -p @semantic-release/changelog semantic-release
- name: Validate conditions
if: ${{ env.DEBUG_MODE == 'true' }}
run: |
echo "RELEASE_VERSION=${{ env.RELEASE_VERSION }}"
echo "CONDITION RELEASE_VERSION != '';=${{ env.RELEASE_VERSION != '' }}"
echo "CONDITION PUBLISH_ARTIFACT == '';=${{ env.RELEASE_VERSION == '' }}"
echo "CONDITION PUBLISH_ARTIFACT == TRUE;=${{ env.PUBLISH_ARTIFACT == 'true' }}"
echo "CONDITION PUBLISH_ARTIFACT == FALSE;=${{ env.PUBLISH_ARTIFACT == 'false' }}"
echo "GITHUB_API_URL=${{ env.GITHUB_API_URL }}"
echo "PUBLISH_ARTIFACT=${{ env.PUBLISH_ARTIFACT }}"
echo "COMMIT_PUSH=${{ env.COMMIT_PUSH }}"
echo "DEBUG_MODE=${{ env.DEBUG_MODE }}"
- name: Set variables From git tag command
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) || ( env.COMMIT_PUSH == 'true' ) }}
run: |
echo "$VER"
echo "RELEASE_VERSION=$(git tag | sort --version-sort | tail -n1 | tr -d 'v')" >> $GITHUB_ENV
- name: Install Mix dependencies
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) || ( env.COMMIT_PUSH == 'true' ) }}
run: mix do local.hex --force, local.rebar --force && mix do deps.clean --unused, deps.get, deps.compile && mix deps.compile
working-directory: Elixir/Konex
- name: Run Mix tests
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) || ( env.COMMIT_PUSH == 'true' ) }}
run: mix test
working-directory: Elixir/Konex
- name: Upgrade mix.exs
if: ${{ ( env.COMMIT_PUSH == 'true' ) }}
run: sed -i 's/@version \".*\"/@version "${{ env.RELEASE_VERSION }}"/g' mix.exs
working-directory: Elixir/Konex
# testing, working but we need to prevent next run
- name: Commit And Push version
if: ${{ ( env.COMMIT_PUSH == 'true' ) }}
uses: github-actions-x/[email protected]
with:
github-token: ${{ env.GITHUB_TOKEN }}
push-branch: main
commit-message: '[skip release] [skip ci] Upgrade version to ${{ env.RELEASE_VERSION }}'
force-add: "true"
files: Elixir/Konex/mix.exs
name: Release Bot
email: [email protected]
- name: Publish to HEX
if: ${{ ( env.PUBLISH_ARTIFACT == 'true' ) }}
run: mix hex.publish --replace --yes
working-directory: Elixir/Konex
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}