-
Notifications
You must be signed in to change notification settings - Fork 24
51 lines (40 loc) · 1.65 KB
/
create-cache-key.yaml
File metadata and controls
51 lines (40 loc) · 1.65 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
name: Create cache key
on:
workflow_call:
outputs:
cache-key:
description: "Cache key"
value: ${{ jobs.create-cache-key.outputs.cache-key }}
env:
REPO-OWNER: ${{ github.repository_owner }}
jobs:
create-cache-key:
name: Create cache key
runs-on: ubuntu-24.04
outputs:
cache-key: ${{ steps.create-cache-key.outputs.cache-key }}
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v5
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile
- name: Cargo update for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: |
set -euo pipefail
TOML="rust/Cargo.toml"
REV="${GITHUB_SHA}"
sed -i -E "/^zingolib[[:space:]]*=/ s/(rev[[:space:]]*=[[:space:]]*\")[^\"]*(\")/\1${REV}\2/" "$TOML"
sed -i -E "/^zingolib[[:space:]]*=/ s/(branch|tag)[[:space:]]*=[[:space:]]*\"[^\"]*\"/rev = \"${REV}\"/" "$TOML"
first_line="$(grep -E '^zingolib[[:space:]]*=' "$TOML")"
echo "zingolib first line => $first_line"
echo "$first_line" | grep -q "rev = \"${REV}\""
echo "$first_line" | grep -vqE '\b(branch|tag)[[:space:]]*='
- name: Store Cargo version
run: echo $(cargo --version) >> rust/cargo_version.txt
- name: Create cache key
id: create-cache-key
run: echo "cache-key=${{ hashFiles('rust/**/Cargo.toml', 'rust/**/Cargo.lock', 'rust/**/*.rs', 'rust/cargo_version.txt') }}" >> $GITHUB_OUTPUT