From b2a8bcd54ff59f571fd5114f080d2d2e20527d50 Mon Sep 17 00:00:00 2001 From: "Oliver Switzer (aider)" Date: Tue, 26 Nov 2024 15:37:43 -0500 Subject: [PATCH] chore: Move version calculation and release creation from ci.yml to publish.yml --- .github/workflows/ci.yml | 55 ----------------------------------- .github/workflows/publish.yml | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6f0767..dd42d9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,58 +42,3 @@ jobs: run: mix test - name: Check formatting run: mix format --check-formatted - - - name: Calculate semantic version - id: versioning - uses: bitshifted/git-auto-semver@v1.1.0 - with: - main_branch: main - create_tag: false - tag_prefix: 'v' - - - name: Update version in mix.exs - env: - RELEASE_VERSION: ${{ steps.versioning.outputs.version-string }} - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - sed -i "s/version: \".*\"/version: \"${RELEASE_VERSION#v}\"/" mix.exs - git add mix.exs - git commit -m "chore: Bump version to ${RELEASE_VERSION}" - git push - - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ steps.versioning.outputs.version-string }} - git tag $VERSION - git push origin $VERSION - gh release create $VERSION \ - --title "Release $VERSION" \ - --generate-notes - - publish: - name: Publish to Hex.pm - needs: test - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - - steps: - - uses: actions/checkout@v3 - with: - ref: main # Get the latest commit with version update - - - name: Set up Elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: '1.16.2' - otp-version: '26.2.5' - - - name: Install dependencies - run: mix deps.get - - - name: Publish to Hex.pm - env: - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} - run: mix hex.publish --yes diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b866810..5d7ca37 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,6 +30,36 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Calculate semantic version + id: versioning + uses: bitshifted/git-auto-semver@v1.1.0 + with: + main_branch: main + create_tag: false + tag_prefix: 'v' + + - name: Update version in mix.exs + env: + RELEASE_VERSION: ${{ steps.versioning.outputs.version-string }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + sed -i "s/version: \".*\"/version: \"${RELEASE_VERSION#v}\"/" mix.exs + git add mix.exs + git commit -m "chore: Bump version to ${RELEASE_VERSION}" + git push + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION=${{ steps.versioning.outputs.version-string }} + git tag $VERSION + git push origin $VERSION + gh release create $VERSION \ + --title "Release $VERSION" \ + --generate-notes + - name: Set up Elixir uses: erlef/setup-beam@v1 with: