diff --git a/.forgejo/workflows/release.yaml b/.forgejo/workflows/release.yaml deleted file mode 100644 index 5e709d0..0000000 --- a/.forgejo/workflows/release.yaml +++ /dev/null @@ -1,361 +0,0 @@ -on: - push: - branches: - - main - paths: - - build.zig.zon - workflow_dispatch: - -jobs: - detect: - runs-on: docker-aarch64 - container: - image: mere/ci:v0.15.0 - outputs: - version_changed: ${{ steps.meta.outputs.version_changed }} - version: ${{ steps.meta.outputs.version }} - old_version: ${{ steps.meta.outputs.old_version }} - tag: ${{ steps.meta.outputs.tag }} - release_name: ${{ steps.meta.outputs.release_name }} - changelog: ${{ steps.meta.outputs.changelog }} - steps: - - name: Git checkout - run: | - git init "$GITHUB_WORKSPACE" - cd "$GITHUB_WORKSPACE" - git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - fetch --tags origin - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - fetch --depth=50 origin "$GITHUB_SHA" - git checkout --detach FETCH_HEAD - - - name: Detect version change - id: meta - run: | - set -eu - cd "$GITHUB_WORKSPACE" - - previous_file= - if git rev-parse --verify "$GITHUB_SHA^" >/dev/null 2>&1; then - git show "$GITHUB_SHA^:build.zig.zon" > previous-build.zig.zon - previous_file=previous-build.zig.zon - fi - - sh .forgejo/scripts/release-ci.sh detect-version-change build.zig.zon "$previous_file" \ - >> "$GITHUB_OUTPUT" - - changelog=$(sh .forgejo/scripts/release-ci.sh changelog) - { - printf 'changelog<> "$GITHUB_OUTPUT" - - - name: No release needed - if: ${{ steps.meta.outputs.version_changed != 'true' }} - run: | - echo "build.zig.zon changed, but .version did not change." - - test: - needs: detect - if: needs.detect.outputs.version_changed == 'true' - runs-on: docker-aarch64 - container: - image: mere/ci:v0.15.0 - steps: - - name: Git checkout - run: | - git init "$GITHUB_WORKSPACE" - cd "$GITHUB_WORKSPACE" - git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - fetch --depth=1 origin "$GITHUB_SHA" - git checkout --detach FETCH_HEAD - - name: Test - run: | - cd "$GITHUB_WORKSPACE" - zig build test --summary all - - release-x86_64: - needs: - - detect - - test - if: needs.detect.outputs.version_changed == 'true' - runs-on: docker - container: - image: mere/ci:v0.15.0 - outputs: - checksum: ${{ steps.build.outputs.checksum }} - steps: - - name: Git checkout - run: | - git init "$GITHUB_WORKSPACE" - cd "$GITHUB_WORKSPACE" - git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - fetch --depth=50 --tags origin "$GITHUB_SHA" - git checkout --detach FETCH_HEAD - - - name: Build and package - id: build - run: | - set -eu - cd "$GITHUB_WORKSPACE" - - version="${{ needs.detect.outputs.version }}" - arch=$(uname -m) - base=$(sh .forgejo/scripts/release-ci.sh asset-base "$version" linux "$arch") - - zig build -Doptimize=ReleaseSmall - mkdir -p dist - cp zig-out/bin/mere "dist/${base}" - - checksum=$(cd dist && sha256sum "$base") - printf 'checksum=%s\n' "$checksum" >> "$GITHUB_OUTPUT" - - - name: Push release tag - run: | - set -eu - cd "$GITHUB_WORKSPACE" - - git config user.name "Mere CI" - git config user.email "no-reply@merelinux.org" - - tag="${{ needs.detect.outputs.tag }}" - if git ls-remote --exit-code --tags origin "refs/tags/${tag}" >/dev/null 2>&1; then - printf 'Tag %s already exists on origin.\n' "$tag" - exit 0 - fi - - git tag -a "$tag" -m "${{ needs.detect.outputs.release_name }}" "$GITHUB_SHA" - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - push origin "refs/tags/${tag}" - - - name: Create release and upload assets - env: - CHANGELOG: ${{ needs.detect.outputs.changelog }} - TAG: ${{ needs.detect.outputs.tag }} - VERSION: ${{ needs.detect.outputs.version }} - COMMIT_SHA: ${{ github.sha }} - run: | - set -eu - cd "$GITHUB_WORKSPACE" - - api_base="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" - auth_header="Authorization: token $GITHUB_TOKEN" - tag="$TAG" - version="$VERSION" - - release_status=$( - curl -sS \ - -o release.json \ - -w '%{http_code}' \ - -H "$auth_header" \ - -H "Accept: application/json" \ - "$api_base/tags/$tag" - ) - - case "$release_status" in - 200) - printf 'Release %s already exists; reusing it.\n' "$tag" - ;; - 404) - python3 .forgejo/scripts/release-body.py > release-create.json - - curl -fsS \ - -X POST \ - -H "$auth_header" \ - -H "Accept: application/json" \ - -H "Content-Type: application/json" \ - --data-binary @release-create.json \ - "$api_base" > release.json - ;; - *) - printf 'Failed to query release %s (HTTP %s).\n' "$tag" "$release_status" >&2 - cat release.json >&2 - exit 1 - ;; - esac - - release_id=$(python3 -c 'import json; print(json.load(open("release.json"))["id"])') - - if [ -z "$release_id" ]; then - printf '%s\n' "Failed to parse release id from API response." >&2 - cat release.json >&2 - exit 1 - fi - - for asset in dist/*; do - name=$(basename "$asset") - status=$( - curl -sS \ - -o upload.json \ - -w '%{http_code}' \ - -X POST \ - -H "$auth_header" \ - -H "Accept: application/json" \ - -F "attachment=@${asset}" \ - "$api_base/$release_id/assets?name=$name" - ) - - case "$status" in - 201) - printf 'Uploaded %s\n' "$name" - ;; - 409) - printf 'Asset %s already exists; skipping.\n' "$name" - ;; - *) - printf 'Failed to upload %s (HTTP %s).\n' "$name" "$status" >&2 - cat upload.json >&2 - exit 1 - ;; - esac - done - - release-aarch64: - needs: - - detect - - test - - release-x86_64 - if: needs.detect.outputs.version_changed == 'true' - runs-on: docker-aarch64 - container: - image: mere/ci:v0.15.0 - outputs: - checksum: ${{ steps.build.outputs.checksum }} - steps: - - name: Git checkout - run: | - git init "$GITHUB_WORKSPACE" - cd "$GITHUB_WORKSPACE" - git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - fetch --depth=50 --tags origin "$GITHUB_SHA" - git checkout --detach FETCH_HEAD - - - name: Build and package - id: build - run: | - set -eu - cd "$GITHUB_WORKSPACE" - - version="${{ needs.detect.outputs.version }}" - arch=$(uname -m) - base=$(sh .forgejo/scripts/release-ci.sh asset-base "$version" linux "$arch") - - zig build -Doptimize=ReleaseSmall - mkdir -p dist - cp zig-out/bin/mere "dist/${base}" - - checksum=$(cd dist && sha256sum "$base") - printf 'checksum=%s\n' "$checksum" >> "$GITHUB_OUTPUT" - - - name: Upload assets - run: | - set -eu - cd "$GITHUB_WORKSPACE" - - api_base="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" - auth_header="Authorization: token $GITHUB_TOKEN" - tag="${{ needs.detect.outputs.tag }}" - - release_status=$( - curl -sS \ - -o release.json \ - -w '%{http_code}' \ - -H "$auth_header" \ - -H "Accept: application/json" \ - "$api_base/tags/$tag" - ) - - if [ "$release_status" != "200" ]; then - printf 'Release %s not found (HTTP %s).\n' "$tag" "$release_status" >&2 - exit 1 - fi - - release_id=$(python3 -c 'import json; print(json.load(open("release.json"))["id"])') - - for asset in dist/*; do - name=$(basename "$asset") - status=$( - curl -sS \ - -o upload.json \ - -w '%{http_code}' \ - -X POST \ - -H "$auth_header" \ - -H "Accept: application/json" \ - -F "attachment=@${asset}" \ - "$api_base/$release_id/assets?name=$name" - ) - - case "$status" in - 201) - printf 'Uploaded %s\n' "$name" - ;; - 409) - printf 'Asset %s already exists; skipping.\n' "$name" - ;; - *) - printf 'Failed to upload %s (HTTP %s).\n' "$name" "$status" >&2 - cat upload.json >&2 - exit 1 - ;; - esac - done - - checksums: - needs: - - detect - - release-x86_64 - - release-aarch64 - if: needs.detect.outputs.version_changed == 'true' - runs-on: docker-aarch64 - container: - image: mere/ci:v0.15.0 - steps: - - name: Upload SHA256SUMS - run: | - set -eu - - printf '%s\n' \ - "${{ needs.release-x86_64.outputs.checksum }}" \ - "${{ needs.release-aarch64.outputs.checksum }}" \ - > SHA256SUMS - - api_base="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases" - auth_header="Authorization: token $GITHUB_TOKEN" - tag="${{ needs.detect.outputs.tag }}" - - curl -fsS \ - -H "$auth_header" \ - -H "Accept: application/json" \ - "$api_base/tags/$tag" > release.json - - release_id=$(python3 -c 'import json; print(json.load(open("release.json"))["id"])') - - status=$( - curl -sS \ - -o upload.json \ - -w '%{http_code}' \ - -X POST \ - -H "$auth_header" \ - -H "Accept: application/json" \ - -F "attachment=@SHA256SUMS" \ - "$api_base/$release_id/assets?name=SHA256SUMS" - ) - - case "$status" in - 201) - printf 'Uploaded SHA256SUMS\n' - ;; - 409) - printf 'SHA256SUMS already exists; skipping.\n' - ;; - *) - printf 'Failed to upload SHA256SUMS (HTTP %s).\n' "$status" >&2 - cat upload.json >&2 - exit 1 - ;; - esac diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml deleted file mode 100644 index d498bd4..0000000 --- a/.forgejo/workflows/test.yaml +++ /dev/null @@ -1,20 +0,0 @@ -on: - pull_request: -jobs: - test: - runs-on: docker-aarch64 - container: - image: mere/ci:v0.15.0 - steps: - - name: Git checkout - run: | - git init "$GITHUB_WORKSPACE" - cd "$GITHUB_WORKSPACE" - git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" - git -c http.extraHeader="Authorization: Bearer $GITHUB_TOKEN" \ - fetch --depth=1 origin "$GITHUB_SHA" - git checkout --detach FETCH_HEAD - - name: Test - run: | - cd "$GITHUB_WORKSPACE" - zig build test --summary all diff --git a/.forgejo/scripts/release-body.py b/.github/scripts/release-body.py similarity index 100% rename from .forgejo/scripts/release-body.py rename to .github/scripts/release-body.py diff --git a/.forgejo/scripts/release-ci.sh b/.github/scripts/release-ci.sh similarity index 100% rename from .forgejo/scripts/release-ci.sh rename to .github/scripts/release-ci.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4e3adc5..3d5f38a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,7 +26,7 @@ jobs: detect: runs-on: ubuntu-24.04-arm container: - image: mere/ci:v0.15.0 + image: mere/ci:v0.18.6 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: @@ -61,7 +61,7 @@ jobs: fi metadata=$(mktemp) - sh .forgejo/scripts/release-ci.sh detect-version-change build.zig.zon "$previous_file" \ + sh .github/scripts/release-ci.sh detect-version-change build.zig.zon "$previous_file" \ > "$metadata" cat "$metadata" >> "$GITHUB_OUTPUT" if [ "${{ github.event_name }}" = "workflow_dispatch" ] && \ @@ -72,7 +72,7 @@ jobs: printf 'tag=%s\n' "${{ inputs.tag_override }}" >> "$GITHUB_OUTPUT" fi - changelog=$(sh .forgejo/scripts/release-ci.sh changelog) + changelog=$(sh .github/scripts/release-ci.sh changelog) { printf 'changelog< release-create.json + python3 .github/scripts/release-body.py > release-create.json python3 -c 'import json; from pathlib import Path; path = Path("release-create.json"); body = json.loads(path.read_text()); body["draft"] = True; path.write_text(json.dumps(body))' curl -fsS \ -X POST \ @@ -245,7 +245,7 @@ jobs: if: needs.detect.outputs.version_changed == 'true' runs-on: ubuntu-24.04 container: - image: mere/ci:v0.15.0 + image: mere/ci:v0.18.6 permissions: contents: write env: @@ -271,7 +271,7 @@ jobs: version="${{ needs.detect.outputs.version }}" arch=$(uname -m) - base=$(sh .forgejo/scripts/release-ci.sh asset-base "$version" linux "$arch") + base=$(sh .github/scripts/release-ci.sh asset-base "$version" linux "$arch") zig build -Doptimize=ReleaseSmall mkdir -p dist @@ -327,7 +327,7 @@ jobs: if: needs.detect.outputs.version_changed == 'true' runs-on: ubuntu-24.04-arm container: - image: mere/ci:v0.15.0 + image: mere/ci:v0.18.6 permissions: contents: write env: @@ -353,7 +353,7 @@ jobs: version="${{ needs.detect.outputs.version }}" arch=$(uname -m) - base=$(sh .forgejo/scripts/release-ci.sh asset-base "$version" linux "$arch") + base=$(sh .github/scripts/release-ci.sh asset-base "$version" linux "$arch") zig build -Doptimize=ReleaseSmall mkdir -p dist @@ -409,7 +409,7 @@ jobs: if: needs.detect.outputs.version_changed == 'true' runs-on: ubuntu-24.04-arm container: - image: mere/ci:v0.15.0 + image: mere/ci:v0.18.6 permissions: contents: write env: @@ -464,7 +464,7 @@ jobs: if: needs.detect.outputs.version_changed == 'true' runs-on: ubuntu-24.04-arm container: - image: mere/ci:v0.15.0 + image: mere/ci:v0.18.6 permissions: contents: write env: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 528b1b8..6fd58a0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-24.04-arm runs-on: ${{ matrix.runs-on }} container: - image: mere/ci:v0.18.1 + image: mere/ci:v0.18.6 steps: - name: Git checkout run: |