2023-08-25 15:25:36 +03:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
#
|
|
|
|
# https://code.forgejo.org/forgejo/runner
|
|
|
|
#
|
|
|
|
# Build the runner binaries and OCI images
|
|
|
|
#
|
|
|
|
# ROLE: forgejo-integration
|
|
|
|
# DOER: release-team
|
|
|
|
# TOKEN: <generated from codeberg.org/release-team>
|
|
|
|
#
|
2023-04-30 19:26:17 +03:00
|
|
|
name: Build release
|
|
|
|
|
2023-08-25 15:25:36 +03:00
|
|
|
on:
|
2023-04-30 19:26:17 +03:00
|
|
|
push:
|
|
|
|
tags: 'v*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
|
|
|
runs-on: self-hosted
|
|
|
|
# root is used for testing, allow it
|
2023-08-25 15:25:36 +03:00
|
|
|
if: secrets.ROLE == 'forgejo-integration' || github.repository_owner == 'root'
|
2023-04-30 19:26:17 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
2023-08-25 15:25:36 +03:00
|
|
|
- name: Increase the verbosity when there are no secrets
|
|
|
|
id: verbose
|
2023-04-30 19:26:17 +03:00
|
|
|
run: |
|
|
|
|
if test -z "${{ secrets.TOKEN }}"; then
|
|
|
|
value=true
|
|
|
|
else
|
|
|
|
value=false
|
|
|
|
fi
|
|
|
|
echo "value=$value" >> "$GITHUB_OUTPUT"
|
2023-08-25 15:25:36 +03:00
|
|
|
|
|
|
|
- name: Sanitize the name of the repository
|
|
|
|
id: repository
|
|
|
|
run: |
|
2024-05-19 13:35:31 +03:00
|
|
|
echo "value=${GITHUB_REPOSITORY##*/}" >> "$GITHUB_OUTPUT"
|
2023-08-25 15:25:36 +03:00
|
|
|
|
|
|
|
- name: create test TOKEN
|
|
|
|
id: token
|
|
|
|
if: ${{ secrets.TOKEN == '' }}
|
2023-04-30 19:26:17 +03:00
|
|
|
run: |
|
2023-08-25 15:25:36 +03:00
|
|
|
apt-get -qq install -y jq
|
2023-04-30 19:26:17 +03:00
|
|
|
url="${{ env.GITHUB_SERVER_URL }}"
|
|
|
|
hostport=${url##http*://}
|
|
|
|
hostport=${hostport%%/}
|
2023-08-25 15:25:36 +03:00
|
|
|
doer=root
|
|
|
|
api=http://$doer:admin1234@$hostport/api/v1/users/$doer/tokens
|
|
|
|
curl -sS -X DELETE $api/release
|
|
|
|
token=$(curl -sS -X POST -H 'Content-Type: application/json' --data-raw '{"name": "release", "scopes": ["all"]}' $api | jq --raw-output .sha1)
|
|
|
|
echo "value=${token}" >> "$GITHUB_OUTPUT"
|
2023-04-30 19:26:17 +03:00
|
|
|
|
2023-08-25 15:25:36 +03:00
|
|
|
- name: version from ref_name
|
|
|
|
id: tag-version
|
2023-04-30 19:26:17 +03:00
|
|
|
run: |
|
2024-05-19 13:35:31 +03:00
|
|
|
version=${GITHUB_REF_NAME##*v}
|
2023-08-25 15:25:36 +03:00
|
|
|
echo "value=$version" >> "$GITHUB_OUTPUT"
|
2023-04-30 19:26:17 +03:00
|
|
|
|
2023-08-25 15:25:36 +03:00
|
|
|
- name: release notes
|
|
|
|
id: release-notes
|
|
|
|
run: |
|
|
|
|
anchor=${{ steps.tag-version.outputs.value }}
|
|
|
|
anchor=${anchor//./-}
|
|
|
|
cat >> "$GITHUB_OUTPUT" <<EOF
|
|
|
|
value<<ENDVAR
|
|
|
|
See https://code.forgejo.org/forgejo/runner/src/branch/main/RELEASE-NOTES.md#$anchor
|
|
|
|
ENDVAR
|
|
|
|
EOF
|
2023-04-30 19:26:17 +03:00
|
|
|
|
2023-08-25 15:25:36 +03:00
|
|
|
- name: build without TOKEN
|
2023-04-30 19:26:17 +03:00
|
|
|
if: ${{ secrets.TOKEN == '' }}
|
2024-05-19 13:35:31 +03:00
|
|
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5
|
2023-04-30 19:26:17 +03:00
|
|
|
with:
|
2023-08-25 15:25:36 +03:00
|
|
|
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
|
|
|
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
|
|
|
repository: "${{ steps.repository.outputs.value }}"
|
|
|
|
doer: root
|
2024-05-19 13:35:31 +03:00
|
|
|
sha: "${{ github.sha }}"
|
|
|
|
release-version: "${{ steps.tag-version.outputs.value }}"
|
2023-08-25 15:25:36 +03:00
|
|
|
token: ${{ steps.token.outputs.value }}
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
release-notes: "${{ steps.release-notes.outputs.value }}"
|
|
|
|
binary-name: forgejo-runner
|
|
|
|
binary-path: /bin/forgejo-runner
|
2023-04-30 19:26:17 +03:00
|
|
|
verbose: ${{ steps.verbose.outputs.value }}
|
|
|
|
|
2023-08-25 15:25:36 +03:00
|
|
|
- name: build with TOKEN
|
2023-04-30 19:26:17 +03:00
|
|
|
if: ${{ secrets.TOKEN != '' }}
|
2024-05-19 13:35:31 +03:00
|
|
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5
|
2023-04-30 19:26:17 +03:00
|
|
|
with:
|
2023-08-25 15:25:36 +03:00
|
|
|
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
|
|
|
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
|
|
|
repository: "${{ steps.repository.outputs.value }}"
|
|
|
|
doer: "${{ secrets.DOER }}"
|
2024-05-19 13:35:31 +03:00
|
|
|
sha: "${{ github.sha }}"
|
|
|
|
release-version: "${{ steps.tag-version.outputs.value }}"
|
2023-08-25 15:25:36 +03:00
|
|
|
token: "${{ secrets.TOKEN }}"
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
release-notes: "${{ steps.release-notes.outputs.value }}"
|
|
|
|
binary-name: forgejo-runner
|
|
|
|
binary-path: /bin/forgejo-runner
|
2023-04-30 19:26:17 +03:00
|
|
|
verbose: ${{ steps.verbose.outputs.value }}
|