From 1aca61d3fd2cc3440bdc701bee7a2e4d8002aeb3 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 22 May 2023 19:57:11 +0200 Subject: [PATCH] Add a full release workflow --- .gitea/workflows/release.yml | 129 +++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..a1d66d5 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,129 @@ +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: 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: Install cargo-deb + uses: https://github.com/brndnmtthws/rust-action-cargo-binstall@v1 + with: + packages: cargo-deb + + - name: Run cargo-deb + uses: https://github.com/actions-rs/cargo@v1 + with: + command: deb + + - 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: target/debian/solar-grabber*.deb + title: 'Release ${{ env.VERSION }}' + + 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: 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_REGISTRIES_LUON_TOKEN }}' + with: + command: publish + args: --registry luon + + release-docker-image: + name: "Release Docker images" + 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 }}