From bfaff92142997a29e57b1e11c6673c4a4c92ca70 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Fri, 26 Jul 2024 05:28:37 +0000 Subject: [PATCH] ci: publish wasm to ghcr ci: publish wasm to ghcr ci: publish wasm to ghcr --- .github/workflows/ci.yml | 7 +++++- .github/workflows/publish.yml | 47 +++++++++++++++++++++++++++++++++++ src/helpers.rs | 3 +++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4330ef8..08aecc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,10 @@ on: - main jobs: example: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - name: Setup example @@ -22,6 +25,8 @@ jobs: args: | setup working-directory: example + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Show sqruff version run: | type sqruff diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5e3a79f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ +name: "Publish to Github Packages" +on: + push: + tags: + - "*" + workflow_dispatch: + inputs: + tag: + description: "The existing tag to publish" + type: "string" + required: true +jobs: + publish-wasm: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.tag || github.ref_name }} + - name: Setup Fluent CI + uses: fluentci-io/setup-fluentci@v5 + with: + wasm: true + plugin: rust + args: | + target_add wasm32-unknown-unknown + build --release --target wasm32-unknown-unknown + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Cache wasm-to-oci + uses: actions/cache@v4 + with: + path: wasm-to-oci_linux-amd64.tar.gz + key: wasm-to-oci-${{ runner.os }} + - name: Publish to the Container registry + run: | + [ -f wasm-to-oci_linux-amd64.tar.gz ] || pkgx wget https://github.com/fluentci-io/wasm-to-oci/releases/download/v0.1.2/wasm-to-oci_linux-amd64.tar.gz + tar xvf wasm-to-oci_linux-amd64.tar.gz + ./wasm-to-oci push target/wasm32-unknown-unknown/release/sqruff.wasm ghcr.io/fluentci-io/sqruff:${{ inputs.tag || github.ref_name }}-wasm diff --git a/src/helpers.rs b/src/helpers.rs index 36a1241..8f9962d 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -2,6 +2,9 @@ use anyhow::Error; use fluentci_pdk::dag; pub fn setup_sqruff() -> Result { + let gh_token = dag().get_env("GITHUB_ACCESS_TOKEN")?; + dag().set_envs(vec![("GITHUB_ACCESS_TOKEN".into(), gh_token)])?; + let stdout = dag() .pkgx()? .with_exec(vec![&format!(