Skip to content

Commit 1b4d261

Browse files
authored
Release to OCI registry (#2587)
* Release to OCI registry * publish as wasip1
1 parent 606b4cc commit 1b4d261

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

.github/actions/publish-release/action.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,59 @@ runs:
7171
with:
7272
subject-path: 'dist/*'
7373

74+
# Publish wasm-tools.wasm as an OCI artifact to GHCR
75+
- name: Install ORAS
76+
uses: oras-project/setup-oras@v1
77+
if: steps.tag.outputs.push_tag == 'yes'
78+
with:
79+
version: '1.2.2'
80+
81+
- name: Install cosign
82+
uses: sigstore/cosign-installer@v3
83+
if: steps.tag.outputs.push_tag == 'yes'
84+
with:
85+
cosign-release: 'v2.4.1'
86+
87+
- name: Extract wasm binary from tarball
88+
if: steps.tag.outputs.push_tag == 'yes'
89+
shell: bash
90+
run: |
91+
version=${{ steps.tag.outputs.version }}
92+
tar xzf "dist/wasm-tools-${version}-wasm32-wasip1.tar.gz" \
93+
--strip-components=1 -C dist \
94+
"wasm-tools-${version}-wasm32-wasip1/wasm-tools.wasm"
95+
96+
- name: Push wasm to GHCR
97+
if: steps.tag.outputs.push_tag == 'yes'
98+
shell: bash
99+
run: |
100+
echo "${{ github.token }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
101+
image_ref="ghcr.io/${{ github.repository_owner }}/wasm-tools-wasm32-wasip1"
102+
version=${{ steps.tag.outputs.version }}
103+
oras push "${image_ref}:${version}" "dist/wasm-tools.wasm:application/wasm"
104+
105+
- name: Push latest tag to GHCR
106+
if: steps.tag.outputs.push_tag == 'yes' && github.ref == 'refs/heads/main'
107+
shell: bash
108+
run: |
109+
image_ref="ghcr.io/${{ github.repository_owner }}/wasm-tools-wasm32-wasip1"
110+
oras push "${image_ref}:latest" "dist/wasm-tools.wasm:application/wasm"
111+
112+
- name: Sign OCI artifact with cosign
113+
if: steps.tag.outputs.push_tag == 'yes'
114+
shell: bash
115+
run: |
116+
image_ref="ghcr.io/${{ github.repository_owner }}/wasm-tools-wasm32-wasip1"
117+
version=${{ steps.tag.outputs.version }}
118+
cosign sign --yes "${image_ref}:${version}"
119+
120+
- name: Sign latest tag with cosign
121+
if: steps.tag.outputs.push_tag == 'yes' && github.ref == 'refs/heads/main'
122+
shell: bash
123+
run: |
124+
image_ref="ghcr.io/${{ github.repository_owner }}/wasm-tools-wasm32-wasip1"
125+
cosign sign --yes "${image_ref}:latest"
126+
74127
# Conditionally run crate publishes if the token is present.
75128
- run: rustup update stable && rustup default stable
76129
shell: bash

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ jobs:
416416
maybe-trigger-tag:
417417
runs-on: ubuntu-latest
418418
needs: ci-status
419+
permissions:
420+
contents: write
421+
id-token: write
422+
attestations: write
423+
packages: write
419424
if: |
420425
always()
421426
&& needs.ci-status.result == 'success'

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212
contents: write
1313
id-token: write
1414
attestations: write
15+
packages: write
1516

1617
jobs:
1718
create_tag:

0 commit comments

Comments
 (0)