From 7cf7a9e3a0a25e2253e4580fa8ee56133ab6e42f Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 27 Jul 2024 15:12:50 +0200 Subject: [PATCH] Switch to Forgejo Actions Also simplify the workflows by using the Rust images. --- .forgejo/workflows/check-lint-test.yml | 28 ++++++++++ .forgejo/workflows/release.yml | 65 ++++++++++++++++++++++ .gitea/workflows/check-lint-test.yml | 48 ----------------- .gitea/workflows/release.yml | 75 -------------------------- 4 files changed, 93 insertions(+), 123 deletions(-) create mode 100644 .forgejo/workflows/check-lint-test.yml create mode 100644 .forgejo/workflows/release.yml delete mode 100644 .gitea/workflows/check-lint-test.yml delete mode 100644 .gitea/workflows/release.yml diff --git a/.forgejo/workflows/check-lint-test.yml b/.forgejo/workflows/check-lint-test.yml new file mode 100644 index 0000000..b87f31a --- /dev/null +++ b/.forgejo/workflows/check-lint-test.yml @@ -0,0 +1,28 @@ +name: "Check, lint and test" + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + +jobs: + check_lint: + name: Check, lint and test + runs-on: rust-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Run cargo check + run: cargo check --all-features + + - name: Run cargo clippy + run: cargo clippy -- -D warnings + + - name: Run cargo fmt + run: cargo fmt --all -- --check + + - name: Run cargo test + run: cargo test --all-features diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..8b2fb6d --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,65 @@ +name: "Release" + +on: + push: + tags: + - v* + +jobs: + release: + name: "Release" + runs-on: rust-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Determine the repository name and version of the release + run: | + REPO_NAME=$(basename $GITHUB_REPOSITORY) + VERSION=${GITHUB_REF_NAME#v} + echo "Releasing version of $REPO_NAME: $VERSION" + echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Get the release notes from the changelog + run: | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + RELEASE_NOTES=$(sed -n -e "/^## \[$VERSION\]/,/^## \[/{//"'!'"p;}" CHANGELOG.md | sed -e '1d;$d') + echo "Release notes:" + echo + echo "$RELEASE_NOTES" + echo "RELEASE_NOTES<<$EOF" >> "$GITHUB_ENV" + echo "$RELEASE_NOTES" >> "$GITHUB_ENV" + echo "$EOF" >> "$GITHUB_ENV" + + - name: Build a release binary + run: | + # FIXME: There is no binary to build, really... + mkdir -p dist + touch dist/no-binaries + + - name: Release to Forgejo + uses: paul/forgejo-release@main + with: + direction: upload + release-dir: dist + release-notes: '${{ env.RELEASE_NOTES }}' + title: 'Release ${{ env.VERSION }}' + token: '${{ secrets.RELEASE_TOKEN }}' + + release-crate: + name: "Release Rust crate" + runs-on: rust-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run cargo publish + run: cargo publish --registry luon + env: + CARGO_REGISTRIES_LUON_INDEX: 'sparse+${{ github.server_url }}/api/packages/${{ github.repository_owner }}/cargo/' + CARGO_REGISTRIES_LUON_TOKEN: 'Bearer ${{ secrets.CARGO_TOKEN }}' diff --git a/.gitea/workflows/check-lint-test.yml b/.gitea/workflows/check-lint-test.yml deleted file mode 100644 index c807925..0000000 --- a/.gitea/workflows/check-lint-test.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "Check, lint and test using Cargo" - -on: - - pull_request - - push - - workflow_dispatch - -jobs: - check_lint: - name: Check, lint and test - runs-on: debian-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Install stable toolchain - uses: https://github.com/actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt, clippy - - - name: Use sparse Cargo index for crates.io - run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml - - - name: Run cargo check - uses: https://github.com/actions-rs/cargo@v1 - with: - command: check - - - name: Run cargo clippy - uses: https://github.com/actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings - - - name: Run cargo fmt - uses: https://github.com/actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - - name: Run cargo test - uses: https://github.com/actions-rs/cargo@v1 - with: - command: test - args: --all-features diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml deleted file mode 100644 index 6a26410..0000000 --- a/.gitea/workflows/release.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: "Release" - -on: - push: - tags: - - "v*" - -jobs: - release: - name: "Release" - runs-on: debian-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Determine the version of the release - run: | - VERSION=${GITHUB_REF_NAME#v} - echo "Releasing version: $VERSION" - echo "VERSION=$VERSION" >> $GITHUB_ENV - - - name: Get the release notes from the changelog - run: | - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - RELEASE_NOTES=$(sed -n -e "/^## \[$VERSION\]/,/^## \[/{//"'!'"p;}" CHANGELOG.md | sed -e '1d;$d') - echo "Release notes:" - echo - echo "$RELEASE_NOTES" - echo "RELEASE_NOTES<<$EOF" >> "$GITHUB_ENV" - echo "$RELEASE_NOTES" >> "$GITHUB_ENV" - echo "$EOF" >> "$GITHUB_ENV" - - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '>=1.20.1' - - - name: Release to Gitea - uses: actions/release-action@main - with: - # This is available by default. - api_key: '${{ secrets.RELEASE_TOKEN }}' - files: FIXME - title: 'Release ${{ env.VERSION }}' - body: '${{ env.RELEASE_NOTES }}' - - release-crate: - name: "Release crate" - runs-on: debian-latest - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install Rust stable toolchain - uses: https://github.com/actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Register the Gitea crate registry with Cargo - run: echo -e '[registries.luon]\nindex = "https://git.luon.net/paul/_cargo-index.git"' >> /root/.cargo/config.toml - - - name: Run cargo publish - uses: https://github.com/actions-rs/cargo@v1 - env: - # This needs to be provided for the repository; no login necessary as a result. - CARGO_REGISTRIES_LUON_TOKEN: '${{ secrets.CARGO_TOKEN }}' - with: - command: publish - args: --registry luon