-
Notifications
You must be signed in to change notification settings - Fork 7
91 lines (88 loc) · 3.62 KB
/
reusable-release-policy-swift.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
name: Build and release a Kubewarden policy written in Swift
on:
workflow_call:
inputs:
oci-target:
type: string
required: true
artifacthub:
description: "check 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@v3.4.4
- uses: actions/checkout@v4
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 artifacthub-pkg.yml is up-to-date
# skip when releasing :latest from main, versions will not match
if: startsWith(github.ref, 'refs/tags/v') && inputs.artifacthub
uses: kubewarden/github-actions/check-artifacthub@v3.4.4
with:
version: ${{ steps.calculate-version.outputs.version }}
- name: install wasm-strip
run: |
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
sudo apt-get -q update
sudo apt-get -q install -y wabt binaryen
- name: Build release
uses: swiftwasm/swiftwasm-action@v5.9
with:
shell-action: swift build -c release --triple wasm32-unknown-wasi --build-path build
- name: optimize policy
run: |
# need to fix file permissions because of some issue with Swift Foundation and filesystem
sudo chmod 777 build/wasm32-unknown-wasi/release/Policy.wasm
wasm-strip build/wasm32-unknown-wasi/release/Policy.wasm
wasm-opt -Os build/wasm32-unknown-wasi/release/Policy.wasm -o policy.wasm
- name: Annotate Wasm module
run: |
make annotated-policy.wasm
- name: Run e2e tests
run: |
make e2e-tests
- name: Release
uses: kubewarden/github-actions/policy-release@v3.4.4
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@v3.4.4