Skip to content

Commit

Permalink
Setup GitHub Actions Package Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Sep 25, 2023
1 parent 2d1c851 commit 3286c7a
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 0 deletions.
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 }}"
108 changes: 108 additions & 0 deletions .github/workflows/part_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
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 && secrets.HEX_API_KEY }}

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 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 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 }}"

0 comments on commit 3286c7a

Please sign in to comment.