Switch to Forgejo Actions
Also simplify the workflows by using the Rust images.
This commit is contained in:
parent
03c51e2a2c
commit
bd31c06979
4 changed files with 133 additions and 168 deletions
29
.forgejo/workflows/check-lint.yml
Normal file
29
.forgejo/workflows/check-lint.yml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
name: "Check and lint"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_lint:
|
||||||
|
name: Check and lint
|
||||||
|
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
|
||||||
|
|
||||||
|
# TODO: Add a test suite first!
|
||||||
|
# - name: Run cargo test
|
||||||
|
# run: cargo test --all-features
|
104
.forgejo/workflows/release.yml
Normal file
104
.forgejo/workflows/release.yml
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
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: This should be figured out in a better manner!
|
||||||
|
BIN_NAME=${REPO_NAME}-x86_64-unknown-linux-gnu
|
||||||
|
cargo build --release
|
||||||
|
mkdir -p dist
|
||||||
|
cp target/release/${REPO_NAME} dist/${BIN_NAME}
|
||||||
|
shasum -a 256 dist/${BIN_NAME} > dist/${BIN_NAME}.sha256sum
|
||||||
|
|
||||||
|
- 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 }}'
|
||||||
|
verbose: true
|
||||||
|
|
||||||
|
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 }}'
|
||||||
|
|
||||||
|
release-docker-image:
|
||||||
|
name: "Release Docker image"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Determine Docker metadata
|
||||||
|
id: meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
git.luon.net/${{ github.repository }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Login to the Forgejo container registry
|
||||||
|
uses: https://github.com/docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.luon.net
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Docker build and push
|
||||||
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
|
@ -1,46 +0,0 @@
|
||||||
name: "Check and lint using Cargo"
|
|
||||||
|
|
||||||
on:
|
|
||||||
- pull_request
|
|
||||||
- push
|
|
||||||
- workflow_dispatch
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_lint:
|
|
||||||
name: Check and lint
|
|
||||||
runs-on: debian-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install Rust stable toolchain
|
|
||||||
uses: https://github.com/actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
profile: minimal
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
# TODO: Add a test suite first!
|
|
||||||
# - name: Run cargo test
|
|
||||||
# uses: https://github.com/actions-rs/cargo@v1
|
|
||||||
# with:
|
|
||||||
# command: test
|
|
||||||
# args: --all-features
|
|
|
@ -1,122 +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 Rust 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: Use sparse Cargo index for crates.io
|
|
||||||
run: echo -e '[registries.crates-io]\nprotocol = "sparse"' >> /root/.cargo/config.toml
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
release-docker-image:
|
|
||||||
name: "Release Docker image"
|
|
||||||
runs-on: debian-latest
|
|
||||||
container:
|
|
||||||
image: ghcr.io/catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: https://github.com/docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
git.luon.net/paul/solar-grabber
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: https://github.com/docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Login to the Gitea Docker registry
|
|
||||||
uses: https://github.com/docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: git.luon.net
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
# This needs to be provided by the repository owner and have the packages scopes enabled.
|
|
||||||
# Note that the default `GITEA_TOKEN` secret does not have this scope enabled.
|
|
||||||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
|
||||||
|
|
||||||
- name: Docker build and push
|
|
||||||
uses: https://github.com/docker/build-push-action@v4
|
|
||||||
env:
|
|
||||||
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
Loading…
Reference in a new issue