Skip to content

Commit e97bcca

Browse files
authored
Merge pull request #41 from cryptosense/fix-release-3
Fix release (again)
2 parents bb6c204 + 5a5c915 commit e97bcca

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
steps:
1313
- name: Checkout the code
1414
uses: actions/checkout@v4
15-
- name: Fetch tags
16-
if: startsWith(github.ref, 'refs/tags/') # https://github.com/actions/checkout/issues/1467
17-
run: git fetch --tags
1815
- name: Set up OCaml
1916
# We can't use setup-ocaml@v3 yet because ocurl can't be installed with it for now
2017
# (curl-config issue).
@@ -24,16 +21,17 @@ jobs:
2421
opam-repositories: |
2522
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
2623
default: https://github.com/ocaml/opam-repository.git
27-
- name: Pin the dependencies
28-
run: opam pin add cs_api_client.dev --no-action .
29-
- name: Install the dependencies
30-
run: opam install --deps-only --with-test .
3124
- name: Set build version
3225
id: build_version
33-
run: echo "value=$(git describe --always HEAD)" >> $env:GITHUB_OUTPUT
26+
run: |
27+
echo "value=$(bash ci/get_version.bash "${{ github.ref_type }}" "${{ github.ref_name }}")" >> $env:GITHUB_OUTPUT
3428
- name: Using version ${{ steps.build_version.outputs.value }}
3529
run: |
3630
echo "Version number: ${{ steps.build_version.outputs.value }}"
31+
- name: Pin the dependencies
32+
run: opam pin add cs_api_client.dev --no-action .
33+
- name: Install the dependencies
34+
run: opam install --deps-only --with-test .
3735
- name: Insert the version number
3836
run: ./ci/subst.bash "${{ steps.build_version.outputs.value }}"
3937
if: startsWith(github.ref, 'refs/tags/')
@@ -54,14 +52,12 @@ jobs:
5452
steps:
5553
- name: Checkout the code
5654
uses: actions/checkout@v4
57-
- name: Fetch tags
58-
if: startsWith(github.ref, 'refs/tags/') # https://github.com/actions/checkout/issues/1467
59-
run: git fetch --tags
6055
- name: Set up Docker Buildx
6156
uses: docker/setup-buildx-action@v3
6257
- name: Set build version
6358
id: build_version
64-
run: echo "value=$(git describe --always HEAD)" >> $GITHUB_OUTPUT
59+
run: |
60+
echo "value=$(./ci/get_version.bash "${{ github.ref_type }}" "${{ github.ref_name }}")" >> $GITHUB_OUTPUT
6561
- name: Using version ${{ steps.build_version.outputs.value }}
6662
run: |
6763
echo "Version number: ${{ steps.build_version.outputs.value }}"

ci/get_version.bash

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
5+
6+
# Generate a version string for use in version substitution in CI.
7+
#
8+
# The first argument should be `github.ref_type` (e.g. `tag` or `branch`). The second
9+
# argument should be `github.ref_name` (e.g. `1.2.3`).
10+
11+
main() {
12+
local ref_type=$1; shift
13+
local ref_name=$1; shift
14+
15+
if [ "$ref_type" = "tag" ]; then
16+
echo "$ref_name"
17+
elif [ "$ref_type" = "branch" ]; then
18+
echo "dev-$(git describe --always HEAD)"
19+
else
20+
echo "Unexpected ref_type: $ref_type" >&2
21+
exit 1
22+
fi
23+
}
24+
25+
main "$@"

0 commit comments

Comments
 (0)