1
1
# brian's standard GitHub Actions release config for Perl 5 modules
2
- # version 20220827.002
2
+ # version 20230604.001
3
3
# https://github.com/briandfoy/github_workflows
4
4
# https://github.com/features/actions
5
5
# This file is licensed under the Artistic License 2.0
6
+ #
7
+ # This action builds a Perl distribution and adds it as a release
8
+ # on GitHub. This does not upload to PAUSE, but that wouldn't be
9
+ # that hard, but that doesn't fit with my workflow since this part
10
+ # happens after everything else has succeeded.
11
+ #
12
+ # This requires that you configure a repository secret named
13
+ # RELEASE_ACTION_TOKEN with a GitHub Personal Access Token
14
+ # that has "read and write" permissions on Repository/Contents
6
15
name : release
7
16
17
+ permissions :
18
+ contents : write
19
+
8
20
on :
9
21
push :
22
+ # tag a release commit with "release-....". This workflow then runs
23
+ # whenever it sees that tag, and doesn't run for other commits.
10
24
tags :
11
25
- ' release-*'
26
+ # With workflow_dispatch, you can trigger this manually. This is
27
+ # especially handy when you want to re-run a job that failed because
28
+ # the token had expired. Update the GitHub secret and re-run on the
29
+ # same commit.
30
+ workflow_dispatch :
31
+
12
32
jobs :
13
33
perl :
34
+ # We need a GitHub secret, so create an Environment named "release"
35
+ # * Go to Settings > Environment (repo settings, not account settings)
36
+ # * Make an environment named "release"
37
+ # * Add a secret named "RELEASE_ACTION_TOKEN" with a GitHub token with repo permissions
38
+ # If you use a different token name, update "RELEASE_ACTION_TOKEN" in the last
39
+ # step in this job.
40
+ environment : release
14
41
runs-on : ${{ matrix.os }}
15
42
strategy :
16
43
matrix :
@@ -31,39 +58,44 @@ jobs:
31
58
# cpanm first, which is easy. I can install IO::Socket::SSL with that,
32
59
# then switch back to cpan. I didn't explore this further, but what you
33
60
# see here hasn't caused problems for me.
34
- # Need HTTP::Tiny 0.055 or later.
61
+ #
62
+ # Need HTTP::Tiny 0.055 or later. Probably don't need it at all since I'm
63
+ # not using cpan here.
64
+ #
65
+ # Test::Manifest is there because it's a thing I do. If you are writing
66
+ # modules and don't know what it is, you don't need it.
35
67
- name : Install cpanm and multiple modules
36
68
run : |
37
69
curl -L https://cpanmin.us | perl - App::cpanminus
38
- cpanm --notest IO::Socket::SSL App::Cpan HTTP::Tiny
39
- cpan -M https://www.cpan.org -T ExtUtils::MakeMaker Test::Manifest
70
+ cpanm --notest IO::Socket::SSL HTTP::Tiny ExtUtils::MakeMaker Test::Manifest
40
71
# Install the dependencies, again not testing them. This installs the
41
72
# module in the current directory, so we end up installing the module,
42
73
# but that's not a big deal.
43
74
- name : Install dependencies
44
75
run : |
45
- cpan -M https://www.cpan.org -T .
76
+ cpanm --notest --installdeps --with-suggests --with-recommends .
77
+ # This makes the distribution and tests it, but assumes by the time we
78
+ # got here, everything else was already tested.
46
79
- name : Create distro
47
80
run : |
48
81
perl Makefile.PL
49
82
make disttest
50
83
make dist 2>/dev/null | grep Created | awk '{ print "ASSET_NAME=" $2 }' >> $GITHUB_ENV
51
84
- name : version
52
- run : echo "::set-output name=version::$(perl -le 'print $ARGV[0] =~ m/(.*?).tar.gz/' *.tar.gz)"
85
+ run : |
86
+ perl -le '($name) = $ARGV[0] =~ m/(.*?).tar.gz/; print qq(name=$name)' *.tar.gz >> $GITHUB_OUTPUT
53
87
id : version
54
- - name : release
55
- uses : actions/create-release@v1
56
- id : create_release
57
- env :
58
- GITHUB_TOKEN : ${{ github.token }}
59
- with :
60
- draft : false
61
- prerelease : false
62
- release_name : ${{ steps.version.outputs.version }}
63
- tag_name : ${{ github.ref }}
64
- body_path : Changes
88
+ - name : Changes extract
89
+ run : |
90
+ perl -00 -lne 'next unless /\A\d+\.\d+(_\d+)?/; print; last' Changes > Changes-latest
91
+ cat Changes-latest
92
+ id : extract
65
93
- name : upload
66
94
uses : softprops/action-gh-release@v1
67
- if : startsWith(github.ref, 'refs/tags/')
68
95
with :
96
+ body_path : Changes-latest
97
+ draft : false
98
+ prerelease : false
99
+ name : ${{ steps.version.outputs.name }}
69
100
files : " *.tar.gz"
101
+ token : ${{ secrets.RELEASE_ACTION_TOKEN }}
0 commit comments