|
6 | 6 | - 'v*.*.*' |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - goreleaser: |
10 | | - name: GoReleaser |
| 9 | + release: |
| 10 | + name: Release |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | permissions: |
13 | 13 | contents: write |
14 | | - pull-requests: write |
| 14 | + packages: write |
15 | 15 | steps: |
16 | 16 | - name: Checkout |
17 | 17 | uses: actions/checkout@v4 |
|
31 | 31 | args: release --clean |
32 | 32 | env: |
33 | 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - name: Setup ORAS |
| 36 | + uses: oras-project/setup-oras@v1 |
| 37 | + with: |
| 38 | + version: latest |
| 39 | + |
| 40 | + - name: Login to GHCR |
| 41 | + env: |
| 42 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + run: echo "$GH_TOKEN" | oras login ghcr.io -u "${{ github.actor }}" --password-stdin |
| 44 | + |
| 45 | + - name: Push binaries to GHCR as OCI artifacts |
| 46 | + env: |
| 47 | + TAG: ${{ github.ref_name }} |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + shopt -s nullglob |
| 52 | +
|
| 53 | + OWNER="${{ github.repository_owner }}" |
| 54 | + OWNER_LC=$(echo "$OWNER" | tr '[:upper:]' '[:lower:]') |
| 55 | + TAG="${TAG:-${{ github.ref_name }}}" |
| 56 | + REV="${{ github.sha }}" |
| 57 | +
|
| 58 | + for d in cmd/*; do |
| 59 | + [ -d "$d" ] || continue |
| 60 | + plugin="$(basename "$d")" |
| 61 | +
|
| 62 | + for binpath in "dist/${plugin}_*/${plugin}" "dist/${plugin}_*/${plugin}.exe"; do |
| 63 | + for bin in $binpath; do |
| 64 | + [ -f "$bin" ] || continue |
| 65 | + dir="$(basename "$(dirname "$bin")")" |
| 66 | + osarch="$(echo "$dir" | sed -E "s/^${plugin}_([A-Za-z0-9-]+)_([A-Za-z0-9-]+).*/\1-\2/")" |
| 67 | + ref="ghcr.io/${OWNER_LC}/${plugin}:${TAG}-${osarch}" |
| 68 | + fname="$(basename "$bin")" |
| 69 | +
|
| 70 | + oras push --artifact-type application/octet-stream \ |
| 71 | + --annotation "org.opencontainers.image.title=${fname}" \ |
| 72 | + --annotation "org.opencontainers.image.version=${TAG}" \ |
| 73 | + --annotation "org.opencontainers.image.revision=${REV}" \ |
| 74 | + --annotation "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \ |
| 75 | + --annotation "org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/releases/tag/${TAG}" \ |
| 76 | + --annotation "org.opencontainers.image.os=${osarch%-*}" \ |
| 77 | + --annotation "org.opencontainers.image.architecture=${osarch#*-}" \ |
| 78 | + "$ref" "$bin:application/octet-stream" |
| 79 | + done |
| 80 | + done |
| 81 | + done |
0 commit comments