Skip to content

Commit d6f79bb

Browse files
authored
Merge pull request #18 from arduino/scerza/go-release
Edit CI workflow to publish releases
2 parents e467e58 + f66c347 commit d6f79bb

File tree

3 files changed

+81
-77
lines changed

3 files changed

+81
-77
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-task.md
2+
name: Release
3+
4+
env:
5+
# As defined by the Taskfile's PROJECT_NAME variable
6+
PROJECT_NAME: serial-discovery
7+
# As defined by the Taskfile's DIST_DIR variable
8+
DIST_DIR: dist
9+
# The project's folder on Arduino's download server for uploading builds
10+
AWS_PLUGIN_TARGET: /discovery/serial-discovery/
11+
ARTIFACT_NAME: dist
12+
13+
on:
14+
push:
15+
tags:
16+
- "v[0-9]+.[0-9]+.[0-9]+*"
17+
18+
jobs:
19+
create-release-artifacts:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Create changelog
29+
uses: arduino/create-changelog@v1
30+
with:
31+
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
32+
filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*'
33+
case-insensitive-regex: true
34+
changelog-file-path: "${{ env.DIST_DIR }}/CHANGELOG.md"
35+
36+
- name: Install Task
37+
uses: arduino/setup-task@v1
38+
with:
39+
repo-token: ${{ secrets.GITHUB_TOKEN }}
40+
version: 3.x
41+
42+
- name: Build
43+
run: task dist:all
44+
45+
- name: Identify Prerelease
46+
# This is a workaround while waiting for create-release action
47+
# to implement auto pre-release based on tag
48+
id: prerelease
49+
run: |
50+
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
51+
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
52+
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
53+
54+
- name: Create Github Release and upload artifacts
55+
uses: ncipollo/release-action@v1
56+
with:
57+
token: ${{ secrets.GITHUB_TOKEN }}
58+
bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md
59+
draft: false
60+
prerelease: ${{ steps.prerelease.outputs.IS_PRE }}
61+
# NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem
62+
# (all the files we need are in the DIST_DIR root)
63+
artifacts: ${{ env.DIST_DIR }}/*
64+
65+
- name: Upload release files on Arduino downloads servers
66+
uses: docker://plugins/s3
67+
env:
68+
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
69+
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
70+
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
71+
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
72+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
73+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/release.yaml

Lines changed: 0 additions & 75 deletions
This file was deleted.

Taskfile.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ vars:
88
sh: echo $(go list ./... | tr '\n' ' ')
99
PROJECT_NAME: "serial-discovery"
1010
DIST_DIR: "dist"
11-
VERSION:
12-
sh: echo "$(git describe --tags --dirty --broken)"
11+
# build vars
12+
COMMIT:
13+
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
14+
TAG:
15+
sh: echo "$(git tag --points-at=HEAD 2> /dev/null | head -n1)"
1316
TIMESTAMP:
1417
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
18+
TIMESTAMP_SHORT:
19+
sh: echo "{{now | date "20060102"}}"
20+
VERSION: "{{if .NIGHTLY}}nightly-{{.TIMESTAMP_SHORT}}{{else if .TAG}}{{.TAG}}{{else}}{{.PACKAGE_NAME_PREFIX}}git-snapshot{{end}}"
1521
CONFIGURATION_PACKAGE: github.com/arduino/serial-discovery/version
1622
LDFLAGS: >
1723
-ldflags

0 commit comments

Comments
 (0)