-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathreusable-release-policy-rust.yml
More file actions
74 lines (72 loc) · 2.95 KB
/
reusable-release-policy-rust.yml
File metadata and controls
74 lines (72 loc) · 2.95 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
name: Build and release a Kubewarden policy written in Rust
on:
workflow_call:
inputs:
oci-target:
type: string
required: true
artifacthub:
description: "generate artifacthub-pkg.yml for submission to ArtifactHub"
required: false
type: boolean
default: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
uses: kubewarden/github-actions/policy-gh-action-dependencies@v4.6.0
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# until https://github.com/actions/checkout/pull/579 is released
fetch-depth: 0
- id: calculate-version
shell: bash
run: |
if [ ${{ startsWith(github.ref, 'refs/tags/v') }} == true ]; then
# Triggered via normal tag.
# Use the latest tag (e.g: v0.1.11) without the `v` prefix.
version=$(git describe --tags --abbrev=0 | cut -c2-)
else
# Triggered via branch, version is not checked in artifacthub.
# Still, `make artifacthub-pkg.yml` needs a proper semver string.
if [ $(git describe --tags) ]; then
# Tag exists, use most recent tag with the number of additional
# commits on top of the tagged object & last commit hash (eg.
# v0.1.11-3-g8a36322), without the `v` prefix.
version=$(git describe --tags | cut -c2-)
else
# Tag doesn't exist, provide bogus version
version="0.0.0-$(git describe --always)-unreleased"
fi
fi
echo "version=$version" >> $GITHUB_OUTPUT
- name: Check that `io.kubewarden.policy.version` annotation is up-to-date
# skip when releasing :latest from main, versions will not match
if: startsWith(github.ref, 'refs/tags/v')
uses: kubewarden/github-actions/check-policy-version@v4.6.0
with:
expected-version: ${{ steps.calculate-version.outputs.version }}
- name: Build and annotate policy
uses: kubewarden/github-actions/policy-build-rust@v4.6.0
- name: Run e2e tests
run: |
make e2e-tests
- name: Release
uses: kubewarden/github-actions/policy-release@v4.6.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
oci-target: ${{ inputs.oci-target }}
policy-version: ${{ steps.calculate-version.outputs.version }}
push-artifacthub:
# skip when releasing :latest from main, versions will not match
if: startsWith(github.ref, 'refs/tags/v') && inputs.artifacthub
needs: release
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
runs-on: ubuntu-latest
steps:
- name: Push artifacthub files to artifacthub branch
uses: kubewarden/github-actions/push-artifacthub@v4.6.0