|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + openwrt_version: |
| 10 | + description: "OpenWrt version" |
| 11 | + type: string |
| 12 | + required: true |
| 13 | + default: "23.05.3" |
| 14 | + openwrt_arch: |
| 15 | + description: "OpenWrt arch" |
| 16 | + type: string |
| 17 | + required: true |
| 18 | + default: "mips_24kc" |
| 19 | + openwrt_target: |
| 20 | + description: "OpenWrt target" |
| 21 | + type: string |
| 22 | + required: true |
| 23 | + default: "ath79" |
| 24 | + openwrt_subtarget: |
| 25 | + description: "OpenWrt subtarget" |
| 26 | + type: string |
| 27 | + required: true |
| 28 | + default: "generic" |
| 29 | + openwrt_vermagic: |
| 30 | + description: "OpenWrt vermagic" |
| 31 | + type: string |
| 32 | + required: true |
| 33 | + default: "auto" |
| 34 | + |
| 35 | +jobs: |
| 36 | + build: |
| 37 | + name: "v${{ matrix.build_env.tag }} - ${{ matrix.build_env.pkgarch }} :: ${{ matrix.build_env.target }}/${{ matrix.build_env.subtarget }} openwrt build" |
| 38 | + runs-on: ubuntu-22.04 |
| 39 | + permissions: |
| 40 | + contents: write |
| 41 | + packages: write |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + build_env: |
| 45 | + - tag: ${{ inputs.openwrt_version || vars.DEFAULT_OPENWRT_VERSION }} |
| 46 | + pkgarch: ${{ inputs.openwrt_arch || vars.DEFAULT_OPENWRT_ARCH }} |
| 47 | + target: ${{ inputs.openwrt_target || vars.DEFAULT_OPENWRT_TARGET }} |
| 48 | + subtarget: ${{ inputs.openwrt_subtarget || vars.DEFAULT_OPENWRT_SUBTARGET }} |
| 49 | + vermagic: ${{ inputs.openwrt_vermagic || vars.DEFAULT_OPENWRT_VERMAGIC }} |
| 50 | + |
| 51 | + env: |
| 52 | + OPENWRT_RELEASE: ${{ matrix.build_env.tag }} |
| 53 | + OPENWRT_ARCH: ${{ matrix.build_env.pkgarch }} |
| 54 | + OPENWRT_TARGET: ${{ matrix.build_env.target }} |
| 55 | + OPENWRT_SUBTARGET: ${{ matrix.build_env.subtarget }} |
| 56 | + OPENWRT_VERMAGIC: ${{ matrix.build_env.vermagic }} |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: checkout openwrt-loki-exporter |
| 60 | + uses: actions/checkout@v4 |
| 61 | + with: |
| 62 | + path: openwrt-loki-exporter |
| 63 | + fetch-depth: 0 |
| 64 | + |
| 65 | + - name: checkout openwrt |
| 66 | + uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + path: openwrt |
| 69 | + repository: openwrt/openwrt |
| 70 | + ref: v${{ matrix.build_env.tag }} |
| 71 | + fetch-depth: 0 |
| 72 | + |
| 73 | + - name: restore cached toolchain |
| 74 | + id: restore-toolchain-cache |
| 75 | + uses: actions/cache/restore@v4 |
| 76 | + with: |
| 77 | + fail-on-cache-miss: false |
| 78 | + key: ${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.tag }}-${{ matrix.build_env.pkgarch }}-${{ matrix.build_env.target }}-${{ matrix.build_env.subtarget }} |
| 79 | + restore-keys: | |
| 80 | + ${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.pkgarch }}- |
| 81 | + path: | |
| 82 | + openwrt/.config |
| 83 | + openwrt/.config.old |
| 84 | + openwrt/feeds.conf |
| 85 | + openwrt/bin/** |
| 86 | + openwrt/build_dir/** |
| 87 | + openwrt/dl/** |
| 88 | + openwrt/feeds/** |
| 89 | + openwrt/package/** |
| 90 | + openwrt/staging_dir/** |
| 91 | + openwrt/tmp/** |
| 92 | +
|
| 93 | + - name: building openwrt toolchain |
| 94 | + if: steps.restore-toolchain-cache.outputs.cache-hit != 'true' |
| 95 | + id: build-toolchain |
| 96 | + run: | |
| 97 | + set -x |
| 98 | + cd openwrt-loki-exporter |
| 99 | + make show-env |
| 100 | + time -p make build-toolchain |
| 101 | + make purge-circular-symlinks |
| 102 | +
|
| 103 | + - name: save toolchain cache |
| 104 | + if: steps.restore-toolchain-cache.outputs.cache-hit != 'true' |
| 105 | + id: save-toolchain-cache |
| 106 | + uses: actions/cache/save@v4 |
| 107 | + with: |
| 108 | + key: ${{ runner.os }}-openwrt-cache-toolchain-${{ matrix.build_env.tag }}-${{ matrix.build_env.pkgarch }}-${{ matrix.build_env.target }}-${{ matrix.build_env.subtarget }} |
| 109 | + path: | |
| 110 | + openwrt/.config |
| 111 | + openwrt/.config.old |
| 112 | + openwrt/feeds.conf |
| 113 | + openwrt/bin/** |
| 114 | + openwrt/build_dir/** |
| 115 | + openwrt/dl/** |
| 116 | + openwrt/feeds/** |
| 117 | + openwrt/package/** |
| 118 | + openwrt/staging_dir/** |
| 119 | + openwrt/tmp/** |
| 120 | +
|
| 121 | + - name: build package |
| 122 | + id: build-package |
| 123 | + run: | |
| 124 | + set -x |
| 125 | + cd openwrt-loki-exporter |
| 126 | + make show-env |
| 127 | + make export-env >> $GITHUB_OUTPUT |
| 128 | + time -p make package |
| 129 | + make prepare-artifacts |
| 130 | +
|
| 131 | + - name: create release |
| 132 | + uses: softprops/action-gh-release@v2 |
| 133 | + with: |
| 134 | + files: | |
| 135 | + loki_exporter_artifacts/* |
0 commit comments