Skip to content

fix: Update to latest goreleaser GH action #74

fix: Update to latest goreleaser GH action

fix: Update to latest goreleaser GH action #74

Workflow file for this run

name: Release
on:
push:
branches: ["master"]
jobs:
release:
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
# Will fetch all history and tags required to generate version
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: "^1.15.5"
- name: "Checkup"
run: go env GOPATH
- name: "Build"
run: go build
- name: "Git Version"
id: generate-version
uses: codacy/[email protected]
- name: "Tag version"
run: |
git tag ${{ steps.generate-version.outputs.version }}
git push --tags "https://codacy:${{ secrets.GITHUB_TOKEN }}@github.com/codacy/pulse-event-cli"
- name: "Login to Docker Hub"
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Release
uses: goreleaser/goreleaser-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: latest
args: release --clean
- name: "Configure AWS Credentials"
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 3600
- name: "Push binaries to artifacts.codacy.com"
run: |
BUCKET=$(aws ssm get-parameter --name "/codacy/artifacts/public/bucket" --query Parameter.Value --output text)
CLOUDFRONT_ID=$(aws ssm get-parameter --name "/codacy/artifacts/public/cloudfront_id" --query Parameter.Value --output text)
BINARY_PATH="codacy/pulse/event-cli"
for binary_directory in $(find dist -type d -iname 'pulse-event-cli_*' | awk -F'/' '{print $2}')
do
binary="$(ls dist/$binary_directory)"
echo "Pushing dist/$binary_directory/$binary to bintray"
aws s3 cp "dist/$binary_directory/$binary" s3://${BUCKET}/${BINARY_PATH}/${{ steps.generate-version.outputs.version }}/$binary_directory/$binary
# If it is a stable version then publish to latest file with current version
if $(echo "${{ steps.generate-version.outputs.version }}" | grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+$'); then
aws s3 cp "dist/$binary_directory/$binary" s3://${BUCKET}/${BINARY_PATH}/latest/$binary_directory/$binary
fi
done
# If it is a stable version then invalidate cloudfront cache
if $(echo "${{ steps.generate-version.outputs.version }}" | grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+$'); then
aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths "/${BINARY_PATH}/latest"
fi
- name: "Push data to pulse"
uses: codacy/[email protected]
with:
args: |
push git deployment \
--api-key ${{ secrets.PULSE_ORGANIZATION_PULSE_API_KEY }} \
--system $GITHUB_REPOSITORY \
--previous-deployment-ref ${{ steps.generate-version.outputs.previous-version }} \
--identifier ${{ steps.generate-version.outputs.version }} \
--timestamp "$(date +%s)"