Use master branch for GitHub Actions #7 #20
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: CI | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
- issue/* | |
# - dev/harai | |
env: | |
AWS_ACCOUNT_ID: '013230744746' | |
RELEASE_ACCESS_KEY_ID: AKIAQGFE5ESVNZ6MPQWV | |
REPO_BUCKET: gutenberg-ext-cflog-repobucket-1k2dvzckylerk | |
GO_VERSION: 1.21.3 | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@master | |
- uses: actions/setup-go@master | |
with: | |
go-version: '~${{env.GO_VERSION}}' | |
- name: Generate build number | |
uses: onyxmueller/build-tag-number@main | |
with: | |
token: ${{secrets.GITHUB_TOKEN}} | |
prefix: build_number_generator | |
- name: Print new build number | |
run: echo "Build number is $BUILD_NUMBER" | |
- name: Save the build number | |
run: echo "$BUILD_NUMBER" > work/BUILD_NUMBER | |
- name: Embed build number into code | |
run: echo "$BUILD_NUMBER" > ./VERSION | |
- run: > | |
go build | |
-ldflags "-X github.com/tarosky/gutenberg-cflog/cflog.Version=$BUILD_NUMBER" | |
-tags lambda.norpc | |
-o work/bootstrap | |
lambda/lambda.go | |
env: | |
GOARCH: amd64 | |
GOOS: linux | |
- run: zip -j cflog.zip ./bootstrap | |
working-directory: work | |
- uses: actions/upload-artifact@main | |
with: | |
name: artifact | |
path: work/cflog.zip | |
- uses: actions/upload-artifact@main | |
with: | |
name: build-number | |
path: work/BUILD_NUMBER | |
release: | |
needs: | |
- build | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/download-artifact@main | |
with: | |
name: artifact | |
- uses: actions/download-artifact@main | |
with: | |
name: build-number | |
- name: set BUILD_NUMBER | |
run: echo "BUILD_NUMBER=$(< ./BUILD_NUMBER)" >> $GITHUB_ENV | |
- name: set ASSET_NAME | |
run: echo "ASSET_NAME=cflog.build-$BUILD_NUMBER-awslambda-provided-amd64.zip" >> $GITHUB_ENV | |
- name: rename | |
run: cp cflog.zip "$ASSET_NAME" | |
- id: create_release | |
uses: softprops/action-gh-release@master | |
with: | |
tag_name: build-${{env.BUILD_NUMBER}} | |
name: Build ${{env.BUILD_NUMBER}} | |
draft: false | |
prerelease: false | |
files: ${{env.ASSET_NAME}} | |
- uses: aws-actions/configure-aws-credentials@main | |
with: | |
aws-access-key-id: ${{env.RELEASE_ACCESS_KEY_ID}} | |
aws-secret-access-key: ${{secrets.AWS_RELEASE_SECRET_ACCESS_KEY}} | |
aws-region: ap-northeast-1 | |
- run: aws s3 cp ./cflog.zip "s3://$REPO_BUCKET/$ASSET_NAME" |