update workflow #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
push: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
build-image: | |
name: Preapre builder image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository }}/builder | |
tags: | | |
type=raw,value=latest | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
- name: Fix permissions | |
run: sudo chmod 777 . cache | |
- name: Prepare container | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
pull: true | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
needs: build-image | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
- name: Cache source archive | |
uses: actions/cache@v4 | |
with: | |
path: | | |
cache | |
prefix | |
wasm-build | |
key: archive-${{ github.sha }} | |
restore-keys: | | |
archive- | |
- name: Build | |
run: docker compose up ci | |
- name: Test | |
run: | | |
corepack yarn install --immutable | |
corepack yarn test | |
- name: Create package tarball | |
run: corepack yarn pack -o libxmlwasm.tgz | |
- name: Upload package tarball | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libxmlwasm.tgz | |
path: libxmlwasm.tgz |