From 7d81ee9d02da9b26cc0c6e0e811a0054adc0f27c Mon Sep 17 00:00:00 2001 From: Anatolios Laskaris Date: Tue, 14 Mar 2023 17:01:39 +0200 Subject: [PATCH] chore: Add release-please (#14) * Add CI * Ignore some shelllints rules * Cleanup --- .github/actionlint.yaml | 3 ++ .github/misc/module.yaml | 5 ++ .github/release-please/config.json | 12 +++++ .github/release-please/manifest.json | 3 ++ .github/workflows/build.yml | 37 ++++++++++++++ .github/workflows/e2e.yml | 18 +++++++ .github/workflows/lint.yml | 35 +++++++++++++ .github/workflows/release.yml | 75 ++++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 18 ------- Makefile | 8 +-- docker-compose.yml | 8 --- version.txt | 1 + 13 files changed, 194 insertions(+), 30 deletions(-) create mode 100644 .github/actionlint.yaml create mode 100644 .github/misc/module.yaml create mode 100644 .github/release-please/config.json create mode 100644 .github/release-please/manifest.json create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/e2e.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release.yml delete mode 100644 Dockerfile delete mode 100644 docker-compose.yml create mode 100644 version.txt diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..be1bfdc --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,3 @@ +self-hosted-runner: + labels: + - builder diff --git a/.github/misc/module.yaml b/.github/misc/module.yaml new file mode 100644 index 0000000..adb1ee0 --- /dev/null +++ b/.github/misc/module.yaml @@ -0,0 +1,5 @@ +version: 0 +type: compiled +name: sqlite3 +volumes: + sites: ./tmp diff --git a/.github/release-please/config.json b/.github/release-please/config.json new file mode 100644 index 0000000..27a88c4 --- /dev/null +++ b/.github/release-please/config.json @@ -0,0 +1,12 @@ +{ + "bootstrap-sha": "c1fa069dcbadb1bf4bb076408ad4ddbd77c7ede0", + "release-type": "simple", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "packages": { + ".": { + "package-name": "sqlite-wasm", + "component": "sqlite-wasm" + } + } +} diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json new file mode 100644 index 0000000..5e39b94 --- /dev/null +++ b/.github/release-please/manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.18.0" +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..62aba47 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build sqlite artifact + +on: + workflow_call: + +jobs: + build: + name: "Build sqlite.wasm" + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup wasi-sdk + run: | + curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sdk-15.0-linux.tar.gz | tar xz -C ./ + mv wasi-sdk-* wasi-sdk + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install Marine + uses: baptiste0928/cargo-install@v1.3.1 + with: + crate: marine + + - name: Build sqlite-wasm + run: make + + - name: Upload sqlite-wasm + uses: actions/upload-artifact@v3 + with: + name: sqlite-wasm + path: sqlite3.wasm + if-no-files-found: error diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..d2df1b0 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,18 @@ +name: "e2e" + +on: + pull_request: + paths-ignore: + - "!**.md" + push: + branches: + - "master" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + build: + name: "sqlite" + uses: ./.github/workflows/build.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..edb1f4b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,35 @@ +name: lint + +on: + pull_request: + types: + - opened + - edited + - synchronize + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + pr: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + reviewdog: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Lint actions + uses: reviewdog/action-actionlint@v1 + env: + SHELLCHECK_OPTS: "-e SC2086 -e SC2207 -e SC2128 -e SC2035" + with: + reporter: github-pr-check + fail_on_error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..72ba350 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: "release" + +on: + push: + branches: + - "master" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + +jobs: + release-please: + runs-on: ubuntu-latest + + outputs: + release-created: ${{ steps.release.outputs['release_created'] }} + tag-name: ${{ steps.release.outputs['tag_name'] }} + version: ${{ steps.release.outputs['version'] }} + pr: ${{ steps.release.outputs['pr'] }} + + steps: + - name: Run release-please + id: release + uses: google-github-actions/release-please-action@v3 + with: + token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }} + command: manifest + config-file: .github/release-please/config.json + manifest-file: .github/release-please/manifest.json + + - name: Show output from release-please + if: steps.release.outputs.releases_created + env: + RELEASE_PLEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }} + run: echo "${RELEASE_PLEASE_OUTPUT}" | jq + + build: + if: needs.release-please.outputs.release-created + needs: release-please + uses: ./.github/workflows/build.yml + + publish: + runs-on: ubuntu-latest + needs: + - release-please + - build + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download sqlite-wasm + uses: actions/download-artifact@v3 + with: + name: sqlite-wasm + path: artifacts/ + + - name: Create archive + run: tar caf artifacts/sqlite3.tar.gz -C ./artifacts/ sqlite3.wasm -C ../.github/misc/ module.yaml + + - name: Generate checksums + id: sum + run: | + sha256sum * | tee > sqlite3_SHA256_SUMS + working-directory: artifacts + + - name: Upload binaries + uses: softprops/action-gh-release@v1 + with: + files: | + artifacts/* + tag_name: ${{ needs.release-please.outputs.tag-name }} diff --git a/.gitignore b/.gitignore index 6a8e533..ccf68e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +wasi-sdk # IntelliJ .idea diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1c2f432..0000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM ubuntu:20.04 - -RUN apt update \ - && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata \ - && apt install -y ca-certificates \ - curl \ - git \ - make \ - pkg-config \ - libtinfo6 \ - cargo - -RUN cargo install marine --version 0.12.7 -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sdk-15.0-linux.tar.gz | tar xz -C / - -VOLUME /code -WORKDIR /code -CMD make diff --git a/Makefile b/Makefile index 41b1bf8..df3d0be 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ TARGET = sqlite3 -CC = /wasi-sdk-15.0/bin/clang -SYSROOT = /wasi-sdk-15.0/share/wasi-sysroot +CC = ./wasi-sdk/bin/clang +SYSROOT = ./wasi-sdk/share/wasi-sysroot TARGET_TRIPLE = wasm32-wasi CFLAGS = -fvisibility=hidden SDK = sdk/logger.h @@ -164,8 +164,8 @@ all: default $(TARGET): $(SQLITE_SRC) $(WRAPPER_SRC) $(CC) -O3 --sysroot=$(SYSROOT) --target=$(TARGET_TRIPLE) $(SQLITE_FLAGS) $(CFLAGS) $(LDFLAGS) -Wl,$(EXPORT_FUNCS) $^ -o $@.wasm - /root/.cargo/bin/marine set version -i ./sqlite3.wasm -v 0.7.0 - /root/.cargo/bin/marine set it -i ./sqlite3.wasm -w sqlite3.wit + marine set version -i ./sqlite3.wasm -v $(shell cat version.txt) + marine set it -i ./sqlite3.wasm -w sqlite3.wit .PRECIOUS: $(TARGET) diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index a3bb07d..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3' -services: - sqlite3: - build: - context: . - container_name: sqlite3_builder - volumes: - - .:/code diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..6633391 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.18.0