|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + |
| 9 | +jobs: |
| 10 | + create-release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Determine plugin name |
| 21 | + id: get_plugin_name |
| 22 | + run: | |
| 23 | + PLUGIN_BUNDLE=$(find . -maxdepth 1 -name "*.indigoPlugin" -type d | head -1) |
| 24 | + if [ -z "$PLUGIN_BUNDLE" ]; then |
| 25 | + echo "Error: No .indigoPlugin directory found in repository root." >&2 |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + PLUGIN_NAME=$(basename "$PLUGIN_BUNDLE" .indigoPlugin) |
| 29 | + echo "plugin_name=$PLUGIN_NAME" >> $GITHUB_OUTPUT |
| 30 | + echo "Detected plugin name: $PLUGIN_NAME" |
| 31 | +
|
| 32 | + - name: Extract version from Info.plist |
| 33 | + id: get_version |
| 34 | + run: | |
| 35 | + PLUGIN_NAME="${{ steps.get_plugin_name.outputs.plugin_name }}" |
| 36 | + VERSION=$(grep -A1 '<key>PluginVersion</key>' "${PLUGIN_NAME}.indigoPlugin/Contents/Info.plist" | grep '<string>' | sed 's/.*<string>\(.*\)<\/string>.*/\1/') |
| 37 | + if [ -z "$VERSION" ]; then |
| 38 | + echo "Error: Could not extract PluginVersion from Info.plist." >&2 |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 42 | + echo "Extracted version: $VERSION" |
| 43 | +
|
| 44 | + - name: Check if release already exists |
| 45 | + id: check_release |
| 46 | + run: | |
| 47 | + VERSION="${{ steps.get_version.outputs.version }}" |
| 48 | + if git rev-parse "v$VERSION" >/dev/null 2>&1; then |
| 49 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 50 | + echo "Release v$VERSION already exists, skipping." |
| 51 | + else |
| 52 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 53 | + echo "Release v$VERSION does not exist, will create." |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Create plugin bundle zip |
| 57 | + if: steps.check_release.outputs.exists == 'false' |
| 58 | + run: | |
| 59 | + PLUGIN_NAME="${{ steps.get_plugin_name.outputs.plugin_name }}" |
| 60 | + zip -r "${PLUGIN_NAME}.indigoPlugin.zip" "${PLUGIN_NAME}.indigoPlugin" |
| 61 | + echo "Created ${PLUGIN_NAME}.indigoPlugin.zip" |
| 62 | +
|
| 63 | + - name: Create GitHub Release |
| 64 | + if: steps.check_release.outputs.exists == 'false' |
| 65 | + uses: softprops/action-gh-release@v2 |
| 66 | + with: |
| 67 | + tag_name: v${{ steps.get_version.outputs.version }} |
| 68 | + name: Release v${{ steps.get_version.outputs.version }} |
| 69 | + generate_release_notes: true |
| 70 | + draft: false |
| 71 | + prerelease: false |
| 72 | + files: ${{ steps.get_plugin_name.outputs.plugin_name }}.indigoPlugin.zip |
0 commit comments