name: Build release on: push: tags: 'v*' jobs: release: runs-on: self-hosted # root is used for testing, allow it if: github.repository_owner == 'forgejo-integration' || github.repository_owner == 'root' steps: - uses: actions/checkout@v3 - id: verbose run: | # if there are no secrets, be verbose if test -z "${{ secrets.TOKEN }}"; then value=true else value=false fi echo "value=$value" >> "$GITHUB_OUTPUT" echo "shell=set -x" >> "$GITHUB_OUTPUT" - id: registry run: | ${{ steps.verbose.outputs.shell }} url="${{ env.GITHUB_SERVER_URL }}" hostport=${url##http*://} hostport=${hostport%%/} echo "host-port=${hostport}" >> "$GITHUB_OUTPUT" if ! [[ $url =~ ^http:// ]] ; then exit 0 fi cat >> "$GITHUB_OUTPUT" <> "$GITHUB_OUTPUT" echo "doer=${doer}" >> "$GITHUB_OUTPUT" - name: allow docker pull/push to forgejo if: ${{ steps.registry.outputs.insecure }} run: |- mkdir /etc/docker cat > /etc/docker/daemon.json < ~/.docker/config.json env: CI_REGISTRY: "${{ env.GITHUB_SERVER_URL }}${{ env.GITHUB_REPOSITORY_OWNER }}" - id: build run: | ${{ steps.verbose.outputs.shell }} tag="${{ github.ref_name }}" tag=${tag##*v} echo "tag=$tag" >> "$GITHUB_OUTPUT" echo "image=${{ steps.registry.outputs.host-port }}/${{ github.repository }}:${tag}" >> "$GITHUB_OUTPUT" - uses: https://github.com/docker/build-push-action@v4 # workaround until https://github.com/docker/build-push-action/commit/d8823bfaed2a82c6f5d4799a2f8e86173c461aba is in @v4 or @v5 is released env: ACTIONS_RUNTIME_TOKEN: '' with: context: . push: true platforms: linux/amd64,linux/arm64 tags: ${{ steps.build.outputs.image }} - run: | ${{ steps.verbose.outputs.shell }} mkdir -p release for arch in amd64 arm64; do docker create --platform linux/$arch --name runner ${{ steps.build.outputs.image }} docker cp runner:/bin/forgejo-runner release/forgejo-runner-$arch shasum -a 256 < release/forgejo-runner-$arch | cut -f1 -d ' ' > release/forgejo-runner-$arch.sha256 docker rm runner done - name: publish release (when TOKEN secret is NOT set) if: ${{ secrets.TOKEN == '' }} uses: https://code.forgejo.org/actions/forgejo-release@v1 with: direction: upload release-dir: release release-notes: "RELEASE-NOTES#${{ steps.build.outputs.tag }}" token: ${{ steps.secrets.outputs.token }} verbose: ${{ steps.verbose.outputs.value }} - name: publish release (when TOKEN secret is set) if: ${{ secrets.TOKEN != '' }} uses: https://code.forgejo.org/actions/forgejo-release@v1 with: direction: upload release-dir: release release-notes: "RELEASE-NOTES#${{ steps.build.outputs.tag }}" token: ${{ secrets.TOKEN }} verbose: ${{ steps.verbose.outputs.value }}