summaryrefslogtreecommitdiffstats
path: root/.forgejo/workflows/build-release.yml
diff options
context:
space:
mode:
Diffstat (limited to '.forgejo/workflows/build-release.yml')
-rw-r--r--.forgejo/workflows/build-release.yml103
1 files changed, 103 insertions, 0 deletions
diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml
new file mode 100644
index 0000000..4e66a0a
--- /dev/null
+++ b/.forgejo/workflows/build-release.yml
@@ -0,0 +1,103 @@
+# 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>
+#
+name: Build release
+
+on:
+ push:
+ tags: 'v*'
+
+jobs:
+ release:
+ runs-on: self-hosted
+ # root is used for testing, allow it
+ if: secrets.ROLE == 'forgejo-integration' || github.repository_owner == 'root'
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Increase the verbosity when there are no secrets
+ id: verbose
+ run: |
+ if test -z "${{ secrets.TOKEN }}"; then
+ value=true
+ else
+ value=false
+ fi
+ echo "value=$value" >> "$GITHUB_OUTPUT"
+
+ - name: Sanitize the name of the repository
+ id: repository
+ run: |
+ echo "value=${GITHUB_REPOSITORY##*/}" >> "$GITHUB_OUTPUT"
+
+ - name: create test TOKEN
+ id: token
+ if: ${{ secrets.TOKEN == '' }}
+ run: |
+ apt-get -qq install -y jq
+ url="${{ env.GITHUB_SERVER_URL }}"
+ hostport=${url##http*://}
+ hostport=${hostport%%/}
+ 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"
+
+ - name: version from ref_name
+ id: tag-version
+ run: |
+ version=${GITHUB_REF_NAME##*v}
+ echo "value=$version" >> "$GITHUB_OUTPUT"
+
+ - 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
+
+ - name: build without TOKEN
+ if: ${{ secrets.TOKEN == '' }}
+ uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5
+ with:
+ forgejo: "${{ env.GITHUB_SERVER_URL }}"
+ owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
+ repository: "${{ steps.repository.outputs.value }}"
+ doer: root
+ sha: "${{ github.sha }}"
+ release-version: "${{ steps.tag-version.outputs.value }}"
+ 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
+ verbose: ${{ steps.verbose.outputs.value }}
+
+ - name: build with TOKEN
+ if: ${{ secrets.TOKEN != '' }}
+ uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5
+ with:
+ forgejo: "${{ env.GITHUB_SERVER_URL }}"
+ owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
+ repository: "${{ steps.repository.outputs.value }}"
+ doer: "${{ secrets.DOER }}"
+ sha: "${{ github.sha }}"
+ release-version: "${{ steps.tag-version.outputs.value }}"
+ token: "${{ secrets.TOKEN }}"
+ platforms: linux/amd64,linux/arm64
+ release-notes: "${{ steps.release-notes.outputs.value }}"
+ binary-name: forgejo-runner
+ binary-path: /bin/forgejo-runner
+ verbose: ${{ steps.verbose.outputs.value }}