Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup GitHub Actions Package Publish #255

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/branch_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ jobs:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"

publish:
name: "Publish"

needs: ["detectToolVersions"]

uses: ./.github/workflows/part_publish.yml
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
110 changes: 110 additions & 0 deletions .github/workflows/part_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
on:
workflow_call:
inputs:
otpVersion:
required: true
type: string
rebarVersion:
required: true
type: string
elixirVersion:
required: true
type: string
releaseName:
required: false
type: string
secrets:
HEX_API_KEY:
required: false

name: "Publish"

jobs:
hex_publish:
name: mix hex.publish

runs-on: ubuntu-latest

if: "${{ inputs.releaseName }}"

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: setupBEAM
with:
otp-version: ${{ inputs.otpVersion }}
rebar3-version: ${{ inputs.rebarVersion }}
elixir-version: ${{ inputs.elixirVersion }}
- uses: actions/cache@v3
with:
path: _build
key: mix_hex_publish-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-${{ hashFiles('mix.exs') }}
restore-keys: |
mix_hex_publish-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-
- uses: actions/cache@v3
with:
path: deps
key: mix_hex_publish-deps-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-${{ hashFiles('mix.exs') }}
restore-keys: |
mix_hex_publish-deps-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-
- run: mix deps.get
- run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}

hex_build:
name: mix hex.build

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: setupBEAM
with:
otp-version: ${{ inputs.otpVersion }}
rebar3-version: ${{ inputs.rebarVersion }}
elixir-version: ${{ inputs.elixirVersion }}
- uses: actions/cache@v3
with:
path: _build
key: mix_hex_build-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-${{ hashFiles('mix.exs') }}
restore-keys: |
mix_hex_build-build-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-
- uses: actions/cache@v3
with:
path: deps
key: mix_hex_build-deps-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-${{ hashFiles('mix.exs') }}
restore-keys: |
mix_hex_build-deps-${{ runner.os }}-${{ steps.setupBEAM.outputs.otp-version }}-
- run: mix deps.get
- run: mix hex.build --output package.tar
- uses: actions/upload-artifact@v3
with:
name: package
path: package.tar

upload:
name: "Upload"

runs-on: ubuntu-latest

if: ${{ inputs.releaseName }}

needs: ["hex_build"]

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: package
path: package.tar
- name: Upload
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload --clobber "${{ inputs.releaseName }}" \
package.tar
11 changes: 11 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ jobs:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"

publish:
name: "Publish"

needs: ["detectToolVersions"]

uses: ./.github/workflows/part_publish.yml
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
14 changes: 14 additions & 0 deletions .github/workflows/tag-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ jobs:
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
releaseName: "${{ github.ref_name }}"

publish:
name: "Publish"

needs: ["detectToolVersions"]

uses: ./.github/workflows/part_publish.yml
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
releaseName: "${{ github.ref_name }}"
secrets:
HEX_API_KEY: "${{ secrets.HEX_API_KEY }}"
14 changes: 14 additions & 0 deletions .github/workflows/tag-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,17 @@ jobs:
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
releaseName: "${{ github.ref_name }}"

publish:
name: "Publish"

needs: ["detectToolVersions"]

uses: ./.github/workflows/part_publish.yml
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
rebarVersion: "${{ needs.detectToolVersions.outputs.rebarVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
releaseName: "${{ github.ref_name }}"
secrets:
HEX_API_KEY: "${{ secrets.HEX_API_KEY }}"
Loading