Skip to content

Commit

Permalink
Setup GitHub Actions Package Publish (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen authored Sep 25, 2023
1 parent 40eb01b commit 36fa44b
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/branch_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ jobs:
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"

publish:
name: "Publish"

needs: ["detectToolVersions"]

uses: ./.github/workflows/part_publish.yml
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
105 changes: 105 additions & 0 deletions .github/workflows/part_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
on:
workflow_call:
inputs:
otpVersion:
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 }}
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 }}
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: .
- name: Upload
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload --clobber "${{ inputs.releaseName }}" \
package.tar
10 changes: 10 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ jobs:
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"

publish:
name: "Publish"

needs: ["detectToolVersions"]

uses: ./.github/workflows/part_publish.yml
with:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
13 changes: 13 additions & 0 deletions .github/workflows/tag-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@ jobs:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
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 }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
releaseName: "${{ github.ref_name }}"
secrets:
HEX_API_KEY: "${{ secrets.HEX_API_KEY }}"
13 changes: 13 additions & 0 deletions .github/workflows/tag-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ jobs:
otpVersion: "${{ needs.detectToolVersions.outputs.otpVersion }}"
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 }}"
elixirVersion: "${{ needs.detectToolVersions.outputs.elixirVersion }}"
releaseName: "${{ github.ref_name }}"
secrets:
HEX_API_KEY: "${{ secrets.HEX_API_KEY }}"

0 comments on commit 36fa44b

Please sign in to comment.