Repository navigation
68 lines (68 loc) · 2.88 KB
/
Copy pathrelease.yml
File metadata and controls
68 lines (68 loc) · 2.88 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
name: Release component
on:
push:
tags: ['v[0-9]+.[0-9]+.[0-9]+']
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.sha }}
- uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Package component and notices
run: nix develop --command make package
- name: Publish raw WASM to OCI without replacing an existing tag
env:
GH_TOKEN: ${{ github.token }}
WKG_OCI_USERNAME: ${{ github.actor }}
WKG_OCI_PASSWORD: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
token=$(curl --fail --silent --show-error --get \
--user "${WKG_OCI_USERNAME}:${GH_TOKEN}" \
--data-urlencode 'service=ghcr.io' \
--data-urlencode 'scope=repository:kkgams/gams/lua:pull,push' \
https://ghcr.io/token | python3 -c '
import json, sys
token = json.load(sys.stdin)["token"]
assert isinstance(token, str) and token, "Missing registry token"
print(token)')
echo "::add-mask::$token"
status=$(curl --silent --show-error \
--output build.nosync/oci-manifest.json --write-out '%{http_code}' \
--header "Authorization: Bearer $token" \
--header 'Accept: application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \
"https://ghcr.io/v2/kkgams/gams/lua/manifests/$version")
case "$status" in
404)
python3 -c '
import json
with open("build.nosync/oci-manifest.json") as response:
errors = json.load(response)["errors"]
assert errors and all(error["code"] in ("MANIFEST_UNKNOWN", "NAME_UNKNOWN") for error in errors), "Registry did not confirm manifest absence"'
;;
200) echo 'OCI tag already exists; refusing to overwrite it.' >&2; exit 1 ;;
*) echo "OCI lookup returned HTTP $status; refusing publication." >&2; exit 1 ;;
esac
# Concurrency serializes this workflow; external publishers must not use this tag.
nix develop --command wkg oci push "ghcr.io/kkgams/gams/lua:$version" build.nosync/plugin.lua.wasm
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
gh release create "$GITHUB_REF_NAME" \
build.nosync/plugin.lua.wasm \
build.nosync/LICENSE \
build.nosync/NOTICE \
build.nosync/SHA256SUMS \
--generate-notes --verify-tag