Merge pull request #282 from cybozu-go/bump-3.1.1 #19
Workflow file for this run
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: release | |
on: | |
push: | |
tags: | |
- 'v*' | |
env: | |
tag: ${GITHUB_REF#refs/tags/v} | |
prerelease: ${{ contains(github.ref, '-') }} | |
jobs: | |
release-image: | |
name: Release Sabakan Image | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup golang | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build image | |
run: make docker-build | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push container image | |
run: | | |
echo "pushing Sabakan image ..." | |
docker tag ghcr.io/cybozu-go/sabakan:latest ghcr.io/cybozu-go/sabakan:${{ env.tag }} | |
docker push ghcr.io/cybozu-go/sabakan:${{ env.tag }} | |
if ${{ env.prerelease }} ; then | |
echo ===== Skip pushing branch tags for pre-release ${{ env.tag }} ===== | |
exit 0 | |
fi | |
BRANCH=$(echo ${{ env.tag }} | cut -d "." -f 1-2) | |
docker tag ghcr.io/cybozu-go/sabakan:latest ghcr.io/cybozu-go/sabakan:$BRANCH | |
docker push ghcr.io/cybozu-go/sabakan:$BRANCH | |
release-github: | |
name: Release GitHub | |
runs-on: ubuntu-22.04 | |
container: | |
image: ghcr.io/cybozu/golang:1.20-jammy # used for ghr, not for go command | |
steps: | |
- name: Create GitHub release | |
run: | | |
OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1) | |
REPOSITORY=$(echo ${{ github.repository }} | cut -d '/' -f 2) | |
if ${{ env.prerelease }}; then | |
PRERELEASE="-prerelease" | |
fi | |
ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${OWNER} -r ${REPOSITORY} -n v${{ env.tag }} ${PRERELEASE} -b "See [CHANGELOG.md](./CHANGELOG.md) for details." v${{ env.tag }} |