From e7b4559d8231a12d0f32c59811bcfa8d61bb0f6d Mon Sep 17 00:00:00 2001 From: Robert Attard Date: Mon, 6 May 2024 11:38:18 -0400 Subject: [PATCH] use reusable workflow for test and release --- .../workflows/{release.yaml => release.yml} | 25 +++++++++++-------- .github/workflows/{main.yml => test.yml} | 17 +++++++------ 2 files changed, 25 insertions(+), 17 deletions(-) rename .github/workflows/{release.yaml => release.yml} (55%) rename .github/workflows/{main.yml => test.yml} (84%) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yml similarity index 55% rename from .github/workflows/release.yaml rename to .github/workflows/release.yml index 903a68f..5d4a3a8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yml @@ -3,30 +3,35 @@ name: Release on: push: tags: - - "v*.*.*" - -env: - GLEAM_VERSION: "1.1.0" - ERLANG_VERSION: 26 + - v*.*.* jobs: - gh-release: + test: + uses: TanklesXL/glint/.github/workflows/test.yml@main + + release-gh: runs-on: ubuntu-latest + needs: [test] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Release uses: softprops/action-gh-release@v1 - hexpm-publish: + release-hex: runs-on: ubuntu-latest environment: publish steps: - uses: actions/checkout@v2 + - uses: actions/cache/restore@v4 + with: + path: ./build/packages + key: deps-${{ hashFiles('manifest.toml') }} - uses: erlef/setup-beam@v1 with: - otp-version: ${{env.ERLANG_VERSION}} - gleam-version: ${{env.GLEAM_VERSION}} + otp-version: 26 + rebar3-version: 3 + gleam-version: "1.1.0" - name: publish to hex env: HEXPM_USER: ${{ secrets.HEXPM_USER }} diff --git a/.github/workflows/main.yml b/.github/workflows/test.yml similarity index 84% rename from .github/workflows/main.yml rename to .github/workflows/test.yml index 67ebcca..37101f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/test.yml @@ -1,13 +1,16 @@ -name: Run Tests +name: Test env: GLEAM_VERSION: "1.1.0" + ERLANG_VERSION: "26" + REBAR3_VERSION: 3 on: push: branches: - main pull_request: + workflow_call: jobs: format: @@ -16,8 +19,8 @@ jobs: - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 with: - otp-version: 26 - rebar3-version: 3 + otp-version: ${{ env.ERLANG_VERSION }} + rebar3-version: ${{ env.REBAR3_VERSION }} gleam-version: ${{ env.GLEAM_VERSION }} - run: gleam format --check src test @@ -34,8 +37,8 @@ jobs: - if: ${{ steps.restore.outputs.cache-hit != 'true' }} uses: erlef/setup-beam@v1 with: - otp-version: 26 - rebar3-version: 3 + otp-version: ${{ env.ERLANG_VERSION }} + rebar3-version: ${{ env.REBAR3_VERSION }} gleam-version: ${{ env.GLEAM_VERSION }} - if: ${{ steps.restore.outputs.cache-hit != 'true' }} run: gleam deps download @@ -61,7 +64,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: ${{matrix.erlang}} - rebar3-version: 3 + rebar3-version: ${{ env.REBAR3_VERSION }} gleam-version: ${{env.GLEAM_VERSION}} - run: gleam test --target erlang @@ -80,7 +83,7 @@ jobs: key: deps-${{ hashFiles('manifest.toml') }} - uses: erlef/setup-beam@v1 with: - otp-version: 26 + otp-version: ${{ env.ERLANG_VERSION }} gleam-version: ${{env.GLEAM_VERSION}} - uses: actions/setup-node@v4 with: