-
Notifications
You must be signed in to change notification settings - Fork 3
115 lines (104 loc) · 3.54 KB
/
release.yml
File metadata and controls
115 lines (104 loc) · 3.54 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Upload new release
on:
workflow_dispatch:
inputs:
tag:
description: Version to use for release tag
default: auto
required: true
commit:
description: Commit to use for tag
default: auto
required: true
increment_major_version:
description: Increment major version
default: false
required: true
increment_minor_version:
description: Increment minor version
default: false
required: true
increment_patch_version:
description: Increment patch version
default: true
required: true
jobs:
update_version:
outputs:
commit: ${{ steps.commit-changes.outputs.commit_long_sha }}
runs-on: ubuntu-latest
if: ${{ github.event.inputs.commit }} == "auto"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.CI_TOKEN }}
fetch-depth: 0
repository: ${{ github.repository }}
ref: main
- name: Create TOML from recipe
run: .github/workflows/create_toml_from_yaml.sh ${GITHUB_WORKSPACE}
- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.9.4
- name: Update version
run: |
if [[ ${{ github.event.inputs.tag }} != "auto" ]]; then
sed -i 's/Version: .*$/Version: ${{ github.event.inputs.tag }}/' DESCRIPTION
elif [[ ${{ github.event.inputs.increment_major_version }} == "true" ]]; then
pixi run use_major_version
elif [[ ${{ github.event.inputs.increment_minor_version }} == "true" ]]; then
pixi run use_minor_version
elif [[ ${{ github.event.inputs.increment_patch_version }} == "true" ]]; then
pixi run use_patch_version
fi
- name: Commit changes to version
id: commit-changes
uses: EndBug/add-and-commit@v10
with:
push: true
message: Update version
create_release:
needs: update_version
runs-on: ubuntu-latest
permissions:
contents: write
env:
INPUT_COMMIT: ${{ github.event.inputs.commit }}
steps:
- name: Determine commit
id: determine-commit
run: |
if [[ ${INPUT_COMMIT} != 'auto' ]]; then
echo "commit=${{ github.event.inputs.commit }}" >> "$GITHUB_OUTPUT"
else
echo "commit=${{ needs.update_version.outputs.commit }}" >> "$GITHUB_OUTPUT"
fi
- name: Checkout HEAD
uses: actions/checkout@v6
with:
ref: ${{ steps.determine-commit.outputs.commit }}
- name: Set tag
id: set-tag
run: |
if [[ ${{ github.event.inputs.tag }} != auto ]]; then
tag=${{ github.event.inputs.tag }}
else
tag=$(grep "Version:" < DESCRIPTION | cut -d ' ' -f 2)
fi
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
- name: Create new tag
id: tag-version
uses: mathieudutour/github-tag-action@v6.2
with:
default_bump: false
default_prerelease_bump: false
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.set-tag.outputs.tag }}
commit_sha: ${{ steps.determine-commit.outputs.commit }}
tag_prefix: ""
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag-version.outputs.new_tag }}
name: Release ${{ steps.tag-version.outputs.new_tag }}
body: ${{ steps.tag-version.outputs.changelog }}