-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (86 loc) · 4.31 KB
/
release.yml
File metadata and controls
90 lines (86 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Release
on:
push:
branches: ["master"]
jobs:
release:
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
with:
# Will fetch all history and tags required to generate version
fetch-depth: 0
- uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # 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/git-version@fa06788276d7492a2af01662649696d249ecf4cb # 2.4.0
- 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: Build docker image
run: docker build -t "codacy/pulse-event-cli:${{ steps.generate-version.outputs.version }}" .
- name: Docker tag
run: |
docker tag "codacy/pulse-event-cli:${{ steps.generate-version.outputs.version }}" "codacy/pulse-event-cli:${{ steps.generate-version.outputs.version }}"
docker tag "codacy/pulse-event-cli:${{ steps.generate-version.outputs.version }}" "codacy/pulse-event-cli:latest"
- name: "Login to Docker Hub"
uses: docker/login-action@42d299face0c5c43a0487c477f595ac9cf22f1a7 # v1.12.0
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push docker image
run: |
docker push "codacy/pulse-event-cli:${{ steps.generate-version.outputs.version }}"
docker push "codacy/pulse-event-cli:latest"
- name: Push binaries to GitHub
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: latest
args: release --clean
- name: "Configure AWS Credentials"
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # 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/pulse-action@dd15d61f61272a7b4395e88de12d4f7d38b61686 # 0.0.3
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)"