Skip to content

migrate to issue bot #22

migrate to issue bot

migrate to issue bot #22

Workflow file for this run

name: Release
on:
push:
branches:
- main
permissions:
contents: write # Enable the creation of GitHub releases
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Run tests
run: |
go test ./... -coverprofile coverage.out
build:
name: Build
runs-on: ubuntu-latest
needs:
- test
env:
CGO_ENABLED: 0
TAG: ${{ github.event.release.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v2
# Do not use fetch-depth 0 as suggested by Goreleaser,
# because we run with --snapshot and do not want issues with
# our non-SemVer tags
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Create artifacts
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# At this point we still don't have a tag. It is just as well, because
# we do not want a SemVer tag, and having a non SemVer tag would break
# GoReleaser (https://goreleaser.com/limitations/semver/).
- name: Upload amd64 assets
uses: actions/upload-artifact@v3
with:
name: cos-tool-amd64
path: dist/cos-tool_linux_amd64_v1/cos-tool
- name: Upload arm64 assets
uses: actions/upload-artifact@v3
with:
name: cos-tool-arm64
path: dist/cos-tool_linux_arm64/cos-tool
ghrelease:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- name: Checkout
uses: actions/checkout@v2
- name: Change perms on GITHUB_WORKSPACE
# Workaround for Git 2.34, see https://github.com/rickstaa/action-create-tag/issues/10
run: |
sudo chown -R root:root $GITHUB_WORKSPACE
sudo chmod -R 0777 $GITHUB_WORKSPACE
- name: Create release tag
uses: rickstaa/action-create-tag@v1
with:
tag: "rel-${{ steps.date.outputs.date }}"
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts/
- name: Prepare artifacts for release
run: |
mkdir -p artifacts/release
find artifacts -type f | awk -F/ '{ print $2 }' | xargs -I {} cp artifacts/{}/cos-tool artifacts/release/{}
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
name: "Release ${{ steps.date.outputs.date }}"
omitBody: true
artifacts: "artifacts/release/*"
tag: "rel-${{ steps.date.outputs.date }}"
token: ${{ secrets.GITHUB_TOKEN }}