diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8803c8..a42c4f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,12 @@ name: Build package on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+*' + workflow_call: + inputs: + runs-on: + description: 'The runner type' + required: true + type: string defaults: run: shell: bash @@ -14,10 +17,8 @@ permissions: read-all jobs: publish: name: "Build" - runs-on: macos-latest + runs-on: "${{ inputs.runs-on }}" environment: build - permissions: - contents: write env: GITHUB_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }} steps: @@ -155,20 +156,24 @@ jobs: run: | set -e rm -rf build/dist/workflow.zip - - name: Create Alfred Workflow - id: create_alfred_workflow + - name: Compress artifacts + id: compress_artifacts env: WORKFLOW_NAME: ${{ vars.WORKFLOW_NAME }} working-directory: build/dist run: | set -e - find . -not -path "./*_cache*" -exec zip --symlinks "../${WORKFLOW_NAME}-v${VERSION}.alfredworkflow" {} + - echo "artifactPath=build/${WORKFLOW_NAME}-v${VERSION}.alfredworkflow" >> $GITHUB_ENV - - name: Release - id: release_workflow - uses: softprops/action-gh-release@v1 + ARTIFACT_NAME=${WORKFLOW_NAME}-v${VERSION}-$(uname -m) + echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV + find . -not -path "./*_cache*" -exec zip --symlinks "../${ARTIFACT_NAME}.zip" {} + + echo "ARTIFACT_PATH=build/${ARTIFACT_NAME}.zip" >> $GITHUB_ENV + - name: Artifact + id: success_artifact + uses: actions/upload-artifact@v4 with: - files: ${{ env.artifactPath }} + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_PATH }} + retention-days: 1 - name: Clean up keychain and build directory id: clean_up if: ${{ always() }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..52af231 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,91 @@ +name: Release package + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' +defaults: + run: + shell: bash +env: + PUB_ENVIRONMENT: bot.github +permissions: read-all + +jobs: + build: + name: "Build" + strategy: + matrix: + os: [macos-14, macos-12] + fail-fast: true + uses: ./.github/workflows/build.yml + with: + runs-on: ${{ matrix.os }} + secrets: inherit + github_release: + name: "Github Release" + needs: build + environment: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Read pubspec.yaml version + id: read_pubspec_version + run: | + set -e + VERSION=$(yq -r '.version' pubspec.yaml) + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Get arm64 artifact + id: download_arm64_artifact + uses: actions/download-artifact@v4 + env: + WORKFLOW_NAME: ${{ vars.WORKFLOW_NAME }} + ARCH: arm64 + with: + name: ${{ env.WORKFLOW_NAME }}-v${{ env.VERSION }}-${{ env.ARCH }} + path: ${{ runner.temp }}/download + - name: Get x86_64 artifact + id: download_x86_64_artifact + uses: actions/download-artifact@v4 + env: + WORKFLOW_NAME: ${{ vars.WORKFLOW_NAME }} + ARCH: x86_64 + with: + name: ${{ env.WORKFLOW_NAME }}-v${{ env.VERSION }}-${{ env.ARCH }} + path: ${{ runner.temp }}/download + - name: Unzip artifacts + env: + WORKFLOW_NAME: ${{ vars.WORKFLOW_NAME }} + id: unzip_artifacts + working-directory: ${{ runner.temp }}/download + run: | + set -e + for ARCH in "arm64" "x86_64"; do + mkdir -p $ARCH + unzip -q ${{ env.WORKFLOW_NAME }}-v${{ env.VERSION }}-${ARCH}.zip -d $ARCH + done + - name: Create Alfred Workflow + id: create_alfred_workflow + env: + WORKFLOW_NAME: ${{ vars.WORKFLOW_NAME }} + working-directory: ${{ runner.temp }}/download + run: | + set -e + mv x86_64/workflow arm64/workflow_intel + pushd arm64 + find . -not -path "./*_cache*" -exec zip --symlinks "../${WORKFLOW_NAME}-v${VERSION}.alfredworkflow" {} + + popd + - name: Release + id: release_workflow + env: + WORKFLOW_NAME: ${{ vars.WORKFLOW_NAME }} + uses: softprops/action-gh-release@v1 + with: + files: ${{ runner.temp }}/download/${{ env.WORKFLOW_NAME }}-v${{ env.VERSION }}.alfredworkflow + - name: Clean up keychain and build directory + id: clean_up + if: ${{ always() }} + run: | + rm -rf $RUNNER_TEMP/download \ No newline at end of file diff --git a/info.plist b/info.plist index 14aafeb..98edf29 100644 --- a/info.plist +++ b/info.plist @@ -65,7 +65,7 @@ escaping 102 script - arch -x86_64 ./workflow -u + [ "$(uname -m)" = "arm64" ] && ./workflow -u || ./workflow_intel -u scriptargtype 1 scriptfile @@ -108,7 +108,7 @@ runningsubtext Fetching the documentation ... script - arch -x86_64 ./workflow -q "{query}" + [ "$(uname -m)" = "arm64" ] && ./workflow -q "{query}" || ./workflow_intel -q "{query}" scriptargtype 0 scriptfile diff --git a/pubspec.yaml b/pubspec.yaml index f3bd92c..81f5a8b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ description: Search the Tailwind CSS documentation using Alfred # Prevent accidental publishing to pub.dev. publish_to: 'none' -version: 2.1.16 +version: 2.2.0 environment: sdk: '>=3.2.0 <4.0.0'