Build Extension #22
Workflow file for this run
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
name: Build Extension | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
setup: | |
name: "Setup" | |
runs-on: ubuntu-latest | |
outputs: | |
ext-ref: ${{ steps.extract-ref.outputs.ref }} | |
manifest: ${{ steps.extract-manifest.outputs.manifest }} | |
steps: | |
- name: Install Dependencies | |
shell: bash | |
run: sudo apt-get install -y dos2unix | |
- name: Extract Ref | |
id: extract-ref | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
ref="" | |
if [ ! -z "${{ github.event.pull_request.number }}" ]; then | |
ref="refs/pull/${{ github.event.pull_request.number }}/merge" | |
elif [ ! -z "${{ github.event.push.ref }}" ]; then | |
ref="${{ github.event.push.ref }}" | |
fi | |
echo "ref=${ref}" >> $GITHUB_OUTPUT | |
- name: Print Ref | |
run: | | |
echo "${{ steps.extract-ref.outputs.ref }}" | |
- name: Checkout | |
uses: actions/checkout@v4.1.0 | |
with: | |
ref: ${{ steps.extract-ref.outpus.ref }} | |
path: plugin | |
- name: Extract Extension Info | |
id: extract-manifest | |
shell: bash | |
run: | | |
manifest=$(cat "./plugin/ExtensionManifest.json" | dos2unix | perl -pe 'chomp if eof') | |
echo "manifest=${manifest}" >> $GITHUB_OUTPUT | |
delim="EOF-${RANDOM}" | |
echo "manifest<<${delim}" >> $GITHUB_ENV | |
echo $manifest >> $GITHUB_ENV | |
echo -e "\n${delim}" >> $GITHUB_ENV | |
- name: Print Extension Info | |
shell: bash | |
run: | | |
echo "[Extension Info Values]" | |
echo "Version : ${{ fromJSON(env.manifest).version }}" | |
echo "Type : ${{ fromJSON(env.manifest).type }}" | |
echo "Package ID : ${{ fromJSON(env.manifest).packageId }}" | |
echo "Target Plugin API Version: ${{ fromJSON(env.manifest).target-plugin-api-version }}" | |
- name: Validate Extension Info | |
if: | | |
fromJSON(env.manifest).type == '' || | |
fromJSON(env.manifest).packageId == '' || | |
fromJSON(env.manifest).version == '' || | |
fromJSON(env.manifest).target-plugin-api-version == '' | |
shell: bash | |
run: | | |
echo "::error file=ExtensionManifest.json::Invalid manifest! Required attributes [version, type, packageId, target-plugin-api-version]" && exit 1 | |
build: | |
needs: [ setup ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Put Manifest into Env | |
shell: bash | |
run: | | |
delim="EOF-${RANDOM}" | |
echo "manifest<<${delim}" >> $GITHUB_ENV | |
echo "${{ needs.steps.output.manifest }}" >> $GITHUB_ENV | |
echo -e "\n${delim}" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4.1.0 | |
with: | |
ref: ${{ needs.setup.outpus.ext-ref }} | |
path: plugin | |
- name: Build Extension | |
id: build_extension | |
uses: Macro-Deck-App/Actions/build-extension@main | |
with: | |
extension-path: plugin | |
artifact-name: ${{ fromJSON(env.manifest).packageId }}-${{ fromJSON(env.manifest).version }} | |
- name: Create/Update Release | |
if: inputs.upsert-release == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifactErrorsFailBuild: false | |
artifacts: './${{ fromJSON(env.manifest).packageId }}-${{ fromJSON(env.manifest).version }}.zip' | |
commit: ${{ github.sha }} | |
generateReleaseNotes: true | |
makeLatest: true | |
replacesArtifacts: true | |
tag: ${{ fromJSON(env.manifest).version }} |