From 25be625b261b7aaabb08d1e1031b559d9e2a2fb1 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Wed, 30 Oct 2024 11:37:55 -0500 Subject: ci: only run on vX.Y.Z tags Signed-off-by: Matt Strapp --- .github/workflows/beam.yml | 23 ++++++++++++++++++++++- .github/workflows/docker.yml | 14 ++++++++++---- .github/workflows/dotnet.yml | 3 ++- .github/workflows/go.yml | 2 +- .github/workflows/jvm.yml | 3 ++- .github/workflows/python.yml | 3 ++- .github/workflows/rust.yml | 21 ++++++++++++++++++++- 7 files changed, 59 insertions(+), 10 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/beam.yml b/.github/workflows/beam.yml index 6ca02b8..a155c5d 100644 --- a/.github/workflows/beam.yml +++ b/.github/workflows/beam.yml @@ -32,4 +32,25 @@ jobs: - name: Lint run: mix format --check-formatted - name: Test - run: mix test \ No newline at end of file + run: mix test + publish: + name: Publish to hex.pm + needs: build-and-test + # Only run on this on proper semver (vX.Y.Z) tags + if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup the BEAM + uses: erlef/setup-beam@v1 + with: + otp-version: latest + elixir-version: latest + gleam-version: latest + - name: Publish + run: mix hex.publish --yes + env: + HEX_API_KEY: ${{ secrets.HEX_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0b10a77..74072c7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,7 +13,6 @@ on: - ".github/workflows/docker.yml" env: - REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: @@ -34,11 +33,18 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Login to GitHub Registry + images: | + ghcr.io/${{ env.IMAGE_NAME }} + rosstheross/${{ env.IMAGE_NAME }} + - name: Login to DockerHub uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + username: rosstheross + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 106d92c..3b2fecb 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -62,7 +62,8 @@ jobs: publish-release: name: Publish Release NuGet to NuGet.org needs: build-and-test - if: ${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') }} + # Only run on this on proper semver (vX.Y.Z) tags + if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 43adef1..da0bda4 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,7 +13,7 @@ on: - ".github/workflows/go.yml" jobs: - build: + build-and-test: name: Build and Test runs-on: ${{ matrix.os }} strategy: diff --git a/.github/workflows/jvm.yml b/.github/workflows/jvm.yml index 62ba3dd..9fb4746 100644 --- a/.github/workflows/jvm.yml +++ b/.github/workflows/jvm.yml @@ -70,7 +70,8 @@ jobs: publish-release: name: Publish Packages to Maven Central and GitHub Packages needs: build-and-test - if: ${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') }} + # Only run on this on proper semver (vX.Y.Z) tags + if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest permissions: packages: write diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 1b5228d..6ad222c 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -39,7 +39,8 @@ jobs: publish: name: Publish to PyPI needs: build-and-test - if: ${{ github.event_name == 'tag' && startsWith(github.ref, 'refs/tags') }} + # Only run on this on proper semver (vX.Y.Z) tags + if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} runs-on: ubuntu-latest permissions: id-token: write diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7defc50..d95200a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -13,7 +13,7 @@ on: - ".github/workflows/rust.yml" jobs: - rust: + build-and-test: name: Build and Test runs-on: ${{ matrix.os }} strategy: @@ -26,3 +26,22 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Test run: cargo test --verbose + + publish: + name: Publish to crates.io + needs: build-and-test + # Only run on this on proper semver (vX.Y.Z) tags + if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Publish + run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }} \ No newline at end of file -- cgit v1.2.3