Build Go App and Publish (v2.7.2) #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build App | |
run-name: Build Go App and Publish (${{ github.event.client_payload.version }}) | |
on: | |
repository_dispatch: | |
types: [artalk-release] | |
env: | |
GO_VERSION: '1.21.3' | |
PKG_NAME: 'github.com/ArtalkJS/Artalk' | |
DOCKER_IMG: ghcr.io/goreleaser/goreleaser-cross | |
CACHE_DIR: /tmp/cache/docker-image | |
VERSION: ${{ github.event.client_payload.version }} | |
DRY_RUN: ${{ github.event.client_payload.dry_run }} | |
jobs: | |
build_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.VERSION }} | |
# disable cache because the err `no space left on device` | |
# - name: Docker Image Cache | |
# id: docker-cache | |
# uses: actions/cache@v3 | |
# with: | |
# path: ${{ env.CACHE_DIR }} | |
# key: docker-image-go-cross-${{ env.GO_VERSION }} | |
- name: Pull Docker Image | |
# if: steps.docker-cache.outputs.cache-hit != 'true' | |
run: | | |
docker pull "${DOCKER_IMG}:v${GO_VERSION}" | |
# mkdir -p "${CACHE_DIR}" | |
# docker save -o "${CACHE_DIR}/go-cross.tar" "${DOCKER_IMG}:v${GO_VERSION}" | |
# - name: Restore Docker Image from Cache | |
# if: steps.docker-cache.outputs.cache-hit == 'true' | |
# run: docker load -i ${CACHE_DIR}/go-cross.tar | |
- name: Setup git-chglog | |
run: | | |
curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \ | |
| grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog | |
git-chglog --version | |
- name: Pre Build | |
run: |- | |
mkdir -p local | |
# github token | |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" > local/.release-env | |
# changelog | |
git-chglog --config .github/chglog/config.yml ${VERSION} > local/release-notes.md | |
# copy config file | |
cp conf/artalk.example.yml artalk.yml | |
- name: Print Relase Notes | |
run: cat local/release-notes.md | |
- name: Build and Release | |
run: | | |
docker run \ | |
--rm \ | |
--privileged \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
-v $(pwd)/sysroot:/sysroot \ | |
-v $(pwd):/go/src/${PKG_NAME} \ | |
-w /go/src/${PKG_NAME} \ | |
-e CGO_ENABLED=1 \ | |
--env-file local/.release-env \ | |
ghcr.io/goreleaser/goreleaser-cross:v${GO_VERSION} \ | |
release --release-notes local/release-notes.md ${{ env.DRY_RUN == 'false' && '' || '--skip-publish' }} |