Skip to content

Commit e24664b

Browse files
committed
mod: add meta tag action for versioning
1 parent 40d1d97 commit e24664b

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

.github/workflows/publish.yml

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- v*
79
workflow_dispatch:
810

911
env:
@@ -14,36 +16,40 @@ jobs:
1416
runs-on: ubuntu-latest
1517

1618
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v2
19-
20-
- name: Login to GitHub Container Registry
21-
uses: docker/login-action@v3
22-
with:
23-
registry: ghcr.io
24-
username: ${{ github.actor }}
25-
password: ${{ secrets.GITHUB_TOKEN }}
26-
27-
- name: Cache cargo bin
28-
id: cache-cargo
29-
uses: actions/cache@v3
30-
env:
31-
cache-name: cache-cargo-bin
32-
with:
33-
path: ~/.cargo/bin
34-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('scripts/install.sh') }}
35-
restore-keys: |
36-
${{ runner.os }}-build-${{ env.cache-name }}-
37-
${{ runner.os }}-build-
38-
${{ runner.os }}-
39-
40-
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
41-
name: Run install script
42-
continue-on-error: false
43-
run: bash scripts/install.sh
44-
45-
- name: Run build script
46-
run: bash scripts/build.sh
47-
48-
- name: Run publish script
49-
run: bash scripts/publish.sh
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
- name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v5
24+
with:
25+
images: ghcr.io/${{ github.actor }}/rust-wasi-hello
26+
- name: Login to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Cache cargo bin
34+
id: cache-cargo
35+
uses: actions/cache@v3
36+
env:
37+
cache-name: cache-cargo-bin
38+
with:
39+
path: ~/.cargo/bin
40+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('scripts/install.sh') }}
41+
restore-keys: |
42+
${{ runner.os }}-build-${{ env.cache-name }}-
43+
${{ runner.os }}-build-
44+
${{ runner.os }}-
45+
46+
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
47+
name: Run install script
48+
continue-on-error: false
49+
run: bash scripts/install.sh
50+
51+
- name: Run build script
52+
run: bash scripts/build.sh
53+
54+
- name: Run publish script
55+
run: bash scripts/publish.sh ${{ steps.meta.outputs.tags }}

scripts/publish.sh

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
2-
2+
tags = "$1"
33
# not running in github actions? use gh cli to login, etc, locally
44
if [ "$GITHUB_ACTIONS" != "true" ]; then
55
# login to the registry
6-
# if running locally, we may need to:
6+
# if running locally, we may need to:
77
# gh auth refresh -h github.com -s write:packages,read:packages
88
gh auth token | docker login ghcr.io --username YOURUSERNAME --password-stdin
99
GH_USER=$(gh api user --jq '.login')
1010
IMAGE_NAME="${GH_USER}/rust-wasi-hello"
1111
fi
1212

1313
PROJECT_NAME="rust_wasi_hello"
14-
REGISTRY_REFERENCE="ghcr.io/${IMAGE_NAME}:latest"
14+
REGISTRY_REFERENCE="ghcr.io/${IMAGE_NAME}:${tags}"
1515

1616
wkg oci push $REGISTRY_REFERENCE target/wasm32-wasip1/release/$PROJECT_NAME.wasm

0 commit comments

Comments
 (0)