-
Notifications
You must be signed in to change notification settings - Fork 137
140 lines (121 loc) · 4.09 KB
/
release.yml
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Release (Manual Step)
on:
workflow_dispatch:
inputs:
name:
description: "Enter - major, minor, patch"
default: "patch"
jobs:
tfswitch-release:
runs-on: ubuntu-latest
steps:
- name: Check if provided input is valid
run: |
echo "Semantic Version: ${{ github.event.inputs.name }}"
VERSION=${{ github.event.inputs.name }}
if [ "$VERSION" != "major" ] && [ "$VERSION" != "minor" ] && [ "$VERSION" != "patch" ]; then
echo "Error: Provided input string must be 'major', 'minor', or 'patch'"
exit 1
fi
# Checkout code from repo
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # required for better experience using pre-releases
fetch-depth: '0'
# Install Go
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.22' # The Go version to download (if necessary) and use
# Double check Go version
- name: Go version
id: Version
run: go version
# Download Go dependencies
- name: Go download
run: go mod download
# Test to see if tfswitch works with --help
- name: Go build
env:
CGO_ENABLED: 0 # Build statically linked binaries
run: mkdir -p build && go build -v -o build/tfswitch && build/tfswitch --help
continue-on-error: false
- name: Create dry tag
uses: anothrNick/github-tag-action@1.69.0
id: semver-tag-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
INITIAL_VERSION: 1.0.0
RELEASE_BRANCHES: master
DEFAULT_BUMP: ${{ github.event.inputs.name }}
PRERELEASE: false
DRY_RUN: true # Only get the tag - dry
VERBOSE: false
# Echo version
- name: Echo version
run: |
echo ${{ steps.semver-tag-dry.outputs.tag }}
# Push the changes to remote
# - name: Push changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: release-${{ steps.semver-tag-dry.outputs.tag }}
# - name: Create Pull Request
# id: cpr
# uses: peter-evans/create-pull-request@v6
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# branch: release-${{ steps.semver-tag-dry.outputs.tag }}
# title: Release ${{ steps.semver-tag-dry.outputs.tag }}
# labels: automerge
# - name: Check outputs
# if: ${{ steps.cpr.outputs.pull-request-number }}
# run: |
# echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
# echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
# - name: Merging release PR
# run: gh pr merge --merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
# env:
# GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Introduce new tag (for real)
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.69.0
id: semver-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
INITIAL_VERSION: 1.0.0
RELEASE_BRANCHES: master
DEFAULT_BUMP: ${{ github.event.inputs.name }}
PRERELEASE: false
DRY_RUN: false # Not dry
VERBOSE: true
# Run goreleaser to create new binaries
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ steps.semver-tag.outputs.tag }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
NO_CREATE_CHANGELOG: true
# Install Python
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.x
# Install Py dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs-material
# Build WWW page
- name: Build page
run: cd www && mkdocs gh-deploy --force
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}