Merge pull request #32 from equinix-ms/dependabot/go_modules/golang.o… #27
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: | |
branches: | |
- main | |
jobs: | |
tag: | |
runs-on: ubuntu-latest | |
outputs: | |
changelog: ${{ steps.tag.outputs.changelog }} | |
tag: ${{ steps.tag.outputs.new_tag }} | |
version: ${{ steps.tag.outputs.new_version }} | |
date: ${{ steps.date.outputs.date }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Save the date | |
id: date | |
run: | | |
echo ::set-output name=date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
- name: Bump version and tag | |
uses: mathieudutour/[email protected] | |
id: tag | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
binaries: | |
name: build binaries | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux] | |
goarch: [amd64, arm64] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: WillAbides/[email protected] | |
with: | |
go-version: '1.19' | |
- name: Build | |
run: | | |
BINARY_NAME=scra-${{matrix.goos}}-${{matrix.goarch}} | |
GOOS=${{matrix.goos}} GOARCH=${{matrix.goarch}} go build -o $BINARY_NAME -v | |
- name: Save artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: scra-artifact | |
path: scra-*-* | |
retention-days: 1 | |
container: | |
name: build container | |
runs-on: ubuntu-latest | |
needs: tag | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push containers | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }} | |
labels: | | |
org.opencontainers.image.title=${{ github.event.repository.name }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
org.opencontainers.image.created=${{ needs.tag.outputs.date }} | |
org.opencontainers.image.version=${{ needs.tag.outputs.tag }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} | |
release: | |
needs: | |
- tag | |
- container | |
- binaries | |
runs-on: ubuntu-latest | |
steps: | |
- name: Restore artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: scra-artifact | |
- name: Create checksums | |
run: | | |
sha256sum scra-*-* | tee scra.sha256 | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ needs.tag.outputs.tag }} | |
name: Release ${{ needs.tag.outputs.version }} | |
body: | | |
Changes in this release: | |
${{ needs.tag.outputs.changelog }} | |
Docker image: `ghcr.io/${{ github.repository }}:${{ needs.tag.outputs.tag }}` | |
files: scra-*-*,scra.sha256 |