-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16d6077
commit a5238da
Showing
1 changed file
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
cabal-file: | ||
# The cabal file. | ||
required: true | ||
type: string | ||
cabal-version: | ||
# Cabal version. | ||
required: false | ||
type: string | ||
default: 3.10.1.0 | ||
release: | ||
# If true, perform a release build. | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
# Concurrency settings. | ||
# Only one job of this workflow will run at a time. | ||
# If a job is currently running, it'll be canceled. | ||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
generate-matrix: | ||
name: "Generate matrix from cabal file" | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Extract the tested GHC versions | ||
id: set-matrix | ||
uses: kleidukos/[email protected] | ||
with: | ||
cabal-file: ${{ inputs.cabal-file }} | ||
ubuntu: true | ||
version: 0.1.6.0 | ||
|
||
build: | ||
name: name: ${{ matrix.ghc }} on ${{ matrix.os }} | ||
needs: generate-matrix | ||
runs-on: ${{ matrix.os }} | ||
continue-on-error: true | ||
strategy: | ||
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | ||
fail-fast: false | ||
env: | ||
PKG_VERSION: "${{ github.event.repository.name }}-${{ github.ref_name }}" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Acquire access token | ||
id: access-token | ||
if: ${{ inputs.release }} | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.GITBOT_APP_ID }} | ||
private-key: ${{ secrets.GITBOT_APP_PRIVATE_KEY }} | ||
|
||
- name: Import common files | ||
if: ${{ inputs.release }} | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'byteverse/.github' | ||
path: '.github-repo' | ||
ref: 'main' | ||
|
||
- name: Run Pre-Release Checks | ||
if: ${{ inputs.release }} | ||
run: | | ||
./.github-repo/.github/check-release.sh "${{ github.ref_name }}" "${{ vars.MAINTAINER_EMAIL }}" | ||
if [ $? -ne 0 ]; | ||
then | ||
echo "${RESULT}" | ||
exit 1 | ||
fi | ||
- name: Check Build Dependencies | ||
run: | | ||
name="workflow_dependencies.sh" | ||
echo "Checking for $name hook..." | ||
file="${{ github.workspace }}/.github/$name" | ||
if [ -x "$file" ]; then | ||
echo "Running hook: $name" | ||
RESULT=$(. "$file") | ||
if [ $? -ne 0 ]; then | ||
echo "$RESULT" | ||
exit 1 | ||
fi | ||
else | ||
echo "Skipping. No hook found." | ||
fi | ||
- name: Set up GHC ${{ matrix.ghc }} | ||
uses: haskell-actions/setup@latest | ||
id: setup | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
cabal-version: ${{ inputs.cabal-version }} | ||
cabal-update: true | ||
|
||
- name: Configure the build | ||
run: | | ||
cabal configure --enable-tests --enable-benchmarks --disable-documentation | ||
cabal build all --dry-run | ||
- name: Install dependencies | ||
run: cabal build all --only-dependencies | ||
|
||
- name: Build | ||
run: cabal build all | ||
|
||
- name: Run tests | ||
run: cabal test all --test-show-details=direct | ||
|
||
- name: Check cabal file | ||
if: ${{ inputs.release }} | ||
run: cabal check | ||
|
||
- name: Build source archive | ||
id: build | ||
if: ${{ inputs.release }} | ||
run: cabal sdist --output-directory ./dist-newstyle | ||
|
||
- name: Build documentation archive | ||
if: ${{ inputs.release }} | ||
run: | | ||
cabal haddock \ | ||
--haddock-html-location="'https://hackage.haskell.org/package/${{ env.PKG_VERSION }}/docs'" \ | ||
--haddock-hyperlink-source \ | ||
--haddock-quickjump \ | ||
--haddock-for-hackage | ||
- name: Create release | ||
if: ${{ inputs.release }} | ||
uses: ncipollo/release-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ steps.access-token.outputs.token }} | ||
with: | ||
allowUpdates: true | ||
artifacts: "./dist-newstyle/*.tar.gz" | ||
artifactErrorsFailBuild: true | ||
generateReleaseNotes: true | ||
|
||
- name: Upload Release Candidate to Hackage | ||
if: ${{ inputs.release }} | ||
run: | | ||
TARBALL="./dist-newstyle/${{ env.PKG_VERSION }}.tar.gz" | ||
cabal upload -u "${{ secrets.HACKAGE_USER }}" -p "${{ secrets.HACKAGE_PASSWORD }}" "${TARBALL}" |