chore(ci): append architecture to apk filename #24
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 | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "*" | |
jobs: | |
generate_matrix: | |
name: Set matrix | |
runs-on: ubuntu-latest | |
outputs: | |
sdks: ${{ steps.out.outputs.sdks }} | |
strategy: | |
matrix: | |
ref: | |
- main # apk | |
- openwrt-23.05 # ipk | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: openwrt/openwrt | |
ref: ${{ matrix.ref }} | |
- name: Set targets | |
id: find_targets | |
run: | | |
REF=${{ matrix.ref }} | |
# sdks | |
JSON='[' | |
FIRST=1 | |
while read -r line; | |
do | |
ARCH=$(echo "$line" | cut -d " " -f 1) | |
[[ $FIRST -ne 1 ]] && JSON="$JSON"',' | |
FIRST=0 | |
JSON="$JSON"'{"arch":"'"$ARCH"'","ref":"'"$REF"'"}' | |
done <<< $(perl ./scripts/dump-target-info.pl architectures 2>/dev/null) | |
JSON="$JSON"']' | |
echo -e "\n---- sdks ----\n" | |
echo "$JSON" | |
echo -e "\n---- sdks ----\n" | |
echo "sdks=$JSON" >> "$GITHUB_OUTPUT" | |
- uses: cloudposse/github-action-matrix-outputs-write@main | |
id: out | |
with: | |
matrix-step-name: ${{ github.job }} | |
matrix-key: ${{ matrix.ref }} | |
outputs: |- | |
sdks: ${{ steps.find_targets.outputs.sdks }} | |
gather_matrix: | |
name: Gather build matrices | |
runs-on: ubuntu-latest | |
needs: generate_matrix | |
outputs: | |
result: ${{ steps.gather.outputs.result }} | |
steps: | |
- uses: cloudposse/github-action-matrix-outputs-read@main | |
id: read | |
with: | |
matrix-step-name: generate_matrix | |
- name: Gather matrices | |
id: gather | |
run: | | |
result=$(jq -c '.sdks[]' <<< '${{ steps.read.outputs.result }}' | jq -c -s add) | |
echo "result=${result}" >> $GITHUB_OUTPUT | |
build: | |
name: Build for ${{ matrix.arch }}-${{ matrix.ref }} | |
runs-on: ubuntu-latest | |
needs: gather_matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(needs.gather_matrix.outputs.result) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Fetch Cloudflared makefile | |
run: | | |
sha=$(cat .nvchecker/sha) | |
curl "https://codeload.github.com/openwrt/packages/tar.gz/$sha" | \ | |
tar -xz --strip=2 "packages-$sha/net/cloudflared" | |
sed -i 's#\.\./\.\.#$(TOPDIR)/feeds/packages#' cloudflared/Makefile | |
- name: Build Package | |
uses: openwrt/gh-action-sdk@main | |
env: | |
ARCH: ${{ matrix.arch }}-${{ matrix.ref }} | |
V: s | |
IGNORE_ERRORS: n m y | |
- name: Append architecture to apk filename | |
if: matrix.ref == 'main' | |
working-directory: bin/packages/${{ matrix.arch }}/action | |
run: | | |
file=$(ls cloudflared*.apk) | |
if [[ $file != *${{ matrix.arch }}* ]]; then | |
filename=${file%.*} | |
extension=${file##*.} | |
mv $file $filename-${{ matrix.arch }}.$extension | |
fi | |
- name: Upload Output Folder | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cloudflared-${{ matrix.arch }}-${{ matrix.ref }} | |
path: bin/packages/${{ matrix.arch }}/action/cloudflared* | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
*.apk | |
*.ipk |