transocks/.gitea/workflows/release.yaml

147 lines
4.4 KiB
YAML
Raw Normal View History

name: release
run-name: ${{ gitea.actor }} release Transocks
on:
push:
2024-10-31 11:46:46 +07:00
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.VERSION }}
changes: ${{ steps.meta.outputs.CHANGES }}
artifact_amd64: ${{ steps.build-amd.outputs.ARTIFACT }}
artifact_arm64: ${{ steps.build-arm.outputs.ARTIFACT }}
steps:
- name: check-out
uses: https://git.mousesoft.ru/actions/checkout@v4
2024-11-01 22:43:08 +07:00
with:
fetch-depth: 0
fetch-tags: true
- name: set-up go
uses: https://git.mousesoft.ru/actions/setup-go@v3
with:
go-version: ">=1.22"
- name: meta
id: meta
env:
SSH_HOST: ${{ secrets.DEB_SSH_HOST }}
run: |
echo "VERSION=$(make version)" >> $GITHUB_OUTPUT
echo 'CHANGES<<EOF' >> $GITHUB_OUTPUT
gawk -f scripts/changes.awk -v version=$(make version-number) CHANGELOG.md >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
mkdir -p out
sed -e "s/DEB_SSH_HOST/$SSH_HOST/g" deploy/dput/mousesoft.json.tpl > out/mousesoft.json
- name: upload dput profile
uses: https://git.mousesoft.ru/actions/upload-artifact@v3
with:
name: mousesoft_dput_profile
path: out/mousesoft.json
overwrite: true
- name: set-up dependencies
run: |
go install github.com/kisielk/errcheck@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/sashamelentyev/usestdlibvars@latest
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
make vendor
- name: lint
run: make lint
- name: golangci-lint
uses: https://github.com/golangci/golangci-lint-action@v6
with:
version: v1.60
- name: build amd64
id: build-amd64
run: |
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-amd64" >> $GITHUB_OUTPUT
2024-11-02 00:35:53 +07:00
GOARCH=amd64 make clean build pkg-deb
- name: upload amd64
uses: https://git.mousesoft.ru/actions/upload-artifact@v3
with:
name: ${{ steps.build-amd64.outputs.ARTIFACT }}
path: |
out/*.changes
out/*.deb
overwrite: true
- name: build arm64
id: build-arm64
run: |
echo "ARTIFACT=transocks-$(make version)_$(go env GOOS)-arm64" >> $GITHUB_OUTPUT
2024-11-02 00:35:53 +07:00
GOARCH=arm64 make clean build pkg-deb
- name: upload arm64
uses: https://git.mousesoft.ru/actions/upload-artifact@v3
with:
name: ${{ steps.build-arm64.outputs.ARTIFACT }}
path: |
out/*.changes
out/*.deb
overwrite: true
deploy:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: download dput profile
uses: https://git.mousesoft.ru/actions/download-artifact@v3-node20
with:
name: mousesoft_dput_profile
path: /etc/dput.d/profiles/
- name: download linux amd64 package
uses: https://git.mousesoft.ru/actions/download-artifact@v3-node20
with:
name: ${{ needs.build_linux.outputs.artifact_amd64 }}
2024-11-02 01:03:02 +07:00
path: out
- name: download linux arm64 package
uses: https://git.mousesoft.ru/actions/download-artifact@v3-node20
with:
name: ${{ needs.build_linux.outputs.artifact_arm64 }}
2024-11-02 01:03:02 +07:00
path: out
- name: deploy packages
env:
SSH_HOST: ${{ secrets.DEB_SSH_HOST }}
SSH_PORT: ${{ secrets.DEB_SSH_PORT }}
SSH_USER: ${{ secrets.DEB_SSH_USER }}
SSH_KEY: ${{ secrets.DEB_SSH_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/key
chmod 0600 ~/.ssh/key
cat >>~/.ssh/config <<END
Host $SSH_HOST
IdentitiesOnly yes
User $SSH_USER
IdentityFile ~/.ssh/key
Port $SSH_PORT
StrictHostKeyChecking no
END
2024-11-02 01:03:02 +07:00
find -O1 out -name '*.changes' -exec dput mousesoft \{\} \;
- name: release
uses: https://git.mousesoft.ru/actions/gitea-release-action@v1
with:
2024-11-02 00:35:53 +07:00
title: "Transocks ${{ needs.build.outputs.version }}"
body: "${{ needs.build.outputs.changes }}"
2024-11-02 01:03:02 +07:00
files: out/*.deb
sha256sum: true
prerelease: true
draft: true